Hello again so soon,
Still writing for a file based database, but now I'm trying to search for key strings to retrieve specific lines of data.
My problem is that even though I can see that my two strings for comparison are identical when I print them, the strcmp function refuses to acknowledge them as such.
Have I used it wrong? Or perhaps made another error in my code?
Any tips appreciated, thanks!
char StudentSearch, FileString, Line, Name, n;
if (fptr == NULL)
printf("Unable to open file");
char StudentSearch, FileString, Line;
fputs("Please enter the student number of the student whose information you would like to view: ", stdout);
while (c != '\n')
if (fgets(StudentSearch, 9, stdin) != NULL && strlen(StudentSearch)==8)
printf("Valid input is %s", StudentSearch);
fscanf (fptr, "%s", FileString);
printf("The file says %s\n", FileString);
while(strcmp(StudentSearch, FileString) != 0);
fgets(Line, 130, fptr);
printf("Invalid Input. Student number must be 7 digits long");