What I want to do is to go into a while loop that uses fgets, and has the criteria that the string read by fgets isn't NULL or the fullstop character "."
What I have is
Which isn't working. I would've though retval is given its value when fgets is called, so then it will be successfully implemented it into the strcmp, but it doesn't seem so.Code:#define LINELENGTH 100 #define EQUAL 0 while ((retval = fgets(buf, LINELENGTH, stdin)) != NULL && strcmp(retval, ".") != EQUAL) { }
All it does at the moment is keep asking me for more strings (even if I enter the fullstop character) and once I press ctrl-D it seg faults.