Good suggestion ;)
--
Mats
Type: Posts; User: matsp
Good suggestion ;)
--
Mats
Yes, but that leaves the newline in the input buffer, which CAN lead to difficulties elsewhere - so we then ALSO need to write code to find out if there is a newline in the string or not, and if not...
char word[15];
fgets(word,16,stdin);
You should NOT lie to fgets() as to the length of your buffer. It's best to use sizeof() rather than a constant, that way, if you change the variable itself,...
scanf("%c"..) leaves a "newline" in the input buffer, so you get an empty line from fgets(), since it reads everything up to the next newline. Add a space after the format of scanf, e.g. scanf("%c...