Originally Posted by
slackwarefan
I love the sarcasm and the condescending tone, but obviously that's not what I'm asking.
There was neither there. But I can provide it if you'd like.
Originally Posted by
slackwarefan
I was thinking of reading the file into a multidimensional array, then performing string functions on each line with a loop. Would this be feasible?
It would, it'd also be dumb. You only need one array, big enough to store the line. Here, try to pay attention this time:
Code:
char buf[ BUFSIZ ] = {0};
FILE *fpin;
FILE *fpout;
int counter;
int record = 0;
fpin = fopen( yourinputfilenameinquotes, "r" );
fpout = fopen( youroutputfilenameinquotes, "w" );
for( counter = 0; fgets( buf, BUFSIZ, fpin ); counter++ )
{
switch( counter % 4 )
{
case 1:
{
char *c = NULL;
fprintf( fpout, "%d:", record++ );
if( (c = strchr( buf, ';' )) )
*c = '\0';
if( (c = strchr( buf, ':' )) )
c++;
fpritnf( fpout, "%s;\n", c );
}
break;
default: /* ignore it */ break;
}
}
You do the rest. Or do it your way, and keep ignoring my advice. In any event, let's see some of your code.
Quzah.