Don't forget that fgets()
retains the newline, but you did not remove it, or add one to the end of test
.
You would spot this if you printed the input using a statement such as:
printf("User ID <<%s>>\n", userID);
inside the loop. The <<
and >>
show you where the string starts and ends, and would reveal the embedded newline.