/* John Pfeiffer, 04jan08 put each line in a file into memory
*/
#include <stdio.h>
#include <stdlib.h>
#define LINE_BUFFER_MAX 512 512
int main(int argc, char* argv[])
{
char unique_string[BUFFER_MAX];
char buffer[BUFFER_MAX];
FILE* fpsrc;
FILE* fpdest;
fpos_t place_in_file;
int instance_count = 0;
test_commandline_parameters( argc, argv );
fpsrc = fopen(argv[1],"r");
fpdest = fopen(argv[1],"w");
if( (fpsrc == NULL) || (fpdest == NULL) )
{ printf("Error opening file(s)\n"); }
else
{
/*while( fgets(buffer,1023,fpsrc != NULL ) */
fgets(unique_string,511,fpsrc);
{
instance_count=0;
fgetpos(fpsrc, place_in_file);
fseek(fptr, 0, SEEK_SET);
while( fgets(buffer, 1023, fpsrc) != NULL )
{
if( strcmp(unique_string,buffer) == 0 )
{
}/* end if */
}/* end while */
}/* end while */
}/* end else */
fclose(fp1);
fclose(fp1);
return 0;
}/* end main */
void test_commandline_parameters( int argc, char* argv[] )
{ int i = 0;
if( (argc < CMDLINE_PARAMETERS) || (argc > CMDLINE_PARAMETERS) )
{ printf("\nCorrect usage is:\n");
printf("%s inputfile outputfile",argv[0]);
exit(1);
}
else
{ while( i < argc )
{ printf("%s ", argv[i]);
i++;
}
printf("in progress...\n\n");
}
}/* end test_commandline_paramters func */