Category : Files from Magazines
Archive   : ITCMAR91.ZIP
Filename : RDBASIC.C

 
Output of file : RDBASIC.C contained in archive : ITCMAR91.ZIP
/****************************************************************
* RDBASIC.C -- example program that reads a BASIC data file *
****************************************************************/

#include /* FILE, fclose(), fopen(), puts(), ... */
#include /* exit(), EXIT_FAILURE */
#include "c2bas2c.h"

struct
{
int i;
char s[20];
float f;
double d;
} buffer;

void main(void)
{
int i;
FILE *infile, *outfile;

/* Open the files for BASIC input and output */
if ( (infile=fopen("BASIC.IN","rb")) == NULL)
{
puts("Error - can't open BASIC.IN!");
exit(EXIT_FAILURE);
}
if ( (outfile=fopen("BASIC.OUT","wb")) == NULL)
{
puts("Error - can't open BASIC.OUT!");
exit(EXIT_FAILURE);
}

/* Process each record */
while (fread(&buffer,sizeof(buffer),1,infile) == 1)
{
/* convert the float & double to Turbo C format */
buffer.f = GWfloatToTCfloat(buffer.f);
buffer.d = GWdoubleToTCdouble(buffer.d);

/* print the buffer on the screen */
printf("%3d %20.20s %5.5f %5.10f\n",
buffer.i, buffer.s, buffer.f, buffer.d);

/* modify the numbers, and make the string uppercase */
buffer.i *= 2;
buffer.f *= 3.25;
buffer.d *= 9.75;
for (i=0; i<20; i++)
buffer.s[i] = toupper(buffer.s[i]);

/* convert the modified values to GWBASIC format */
buffer.f = TCfloatToGWfloat(buffer.f);
buffer.d = TCdoubleToGWdouble(buffer.d);

/* write the buffer to the output file */
if (fwrite(&buffer,sizeof(buffer),1,outfile) != 1)
puts("Error writing buffer!");
}

fclose(infile);
fclose(outfile);
}


  3 Responses to “Category : Files from Magazines
Archive   : ITCMAR91.ZIP
Filename : RDBASIC.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/