Need help splitting input file into multiple output files
Hello to all,
I am new to programming and need help with a program. I am trying to split one large file into multiple smaller files. The smaller files have to start from a line that starts with "LOCUS.." and end at a line that starts with "//..." The way the original file is setup, this occurs several times.
Also, I need the output files to be titled a specific way. In the first line that contains "LOCUS", I need the second word that appears to be my title. It is a unique ID. I know I can use strtok but, I am not sure how to set it up.
Below is the code I have so far. Its not much. Any help would be appreciated.
main( int argc, char **argv )
FILE *input ;
FILE *output ;
char data ;
if( ! ( input = fopen( argv, "r" ) ) )
printf( "COULD NOT OPEN FILE %s - Exit!\n", argv) ;
// put the accension id as file name
output = fopen( "id" , "w" ) ;
while( (fgets(data, 100000, input)) != "//" )
fputs( data, output) ;
fclose (input) ;
fclose (output) ;