Is this code OK?
Code:
...
char buf[BUFSIZ];
while(1)
{
fgets(buf,BUFSIZ,stdin);
if(feof(stdin))
break;
printf("%s",buf);
}
...
I'm supposed to read one word at a time and process it in some way until user enters Ctrl-Z
Is it ok to use feof(stdin)?
And one more qustion; since fgets read newline character and store it in buffer do I have to loop to that position and set '\0' on that place, or is ti Ok '\n' to stay there because sometimes it can be annoying for example char name[100]; to have '\n' in the name
Thanks