What is the difference between fgets()
and gets()
?
I am trying break my loop when the user hits just \"enter\". It\'s working well with
you can use fgets()
with STDIN instead.
This function is secured and always insert a '\0' at the string end.
An example:
char inputbuffer[10];
char *p;
p = fgets(inputbuffer, sizeof(inputbuffer), stdin);
printf(">%s<\n", p); /* p is NULL on error, but printf is fair */
You'll get at most 9 characters + '\0', in this example.