I have putten together this code for searching a text file for a users string (User's ID), how every i am aving some error that i dont knw how to fix and was hoping someone could help me. Thanks in advance.
#include<stdio.h>
#include<string.h>
#inlcude<stdlib.h>
int main()
{
FILE *fpcust;
int i, len_string;
int searchID [30];
int temp[30];
printf("Please enter the user ID.");
scanf("%d", &searchID);
fpcust = fopen ("c:\\customers.txt", "r");
rewind(fpcust);
if ( fpcust == NULL)
{
printf("File cound not be opened.");
exit(0);
}
len_string = strlen(searchID);
while (!feof ( fpcust ) )
{
for (i = 0; i < len_string; i++)
{
temp[i] = fgetc ( fpcust );
temp[i] = '\0';
}
//stricmp used for comparing both strings
if ( stricmp ( searchID, temp ) == 0)
{
printf("The ID was found");
fflush ( fpcust );
fclose( fpcust);
getchar();
exit(1);
}
else
{
printf("No matches found.");
getchar();
exit (1);
}
fseek ( fpcust, -(len_string - 1), 1);
}
fclose ( fpcust );
}