So we have
scanf(%d, &newstudentID)
so presumably
newstudentID
is of type int. Then a bit later we have
strcmp(newstudentID, buffer)
Here, we are passing an
int to
strcmp
as the first argument, but strcmp() is expecting a
char *
. So strcmp() uses whatever the student ID is as an address into memory - perhaps
42, which is almost certainly not an address that you have read access to, and tries to use that as a starting point for a string. Bad Things happen at this point.
There's no reason you can't use fscanf() to read "stData.txt" e.g.
int testID;
while( fscanf(input, "%d", &testID) {
if(testID == newstudentID) {
printf("ID already in use\n");
}
}