What does it mean?
fgets(y, sizeof(y), stdin);
thx!
What does it mean?
fgets(y, sizeof(y), stdin);
thx!
please use more descriptive post titles as it will help you get better answers. and try searching on your own first, even if your compiler's editor did not include a help reference for your standard library functions, there are many resources elsewhere.#include <stdio.h>
char *fgets(char *s, int n, FILE *stream);
Description
Gets a string from a stream.
fgets reads characters from stream into the string s. The function stops reading when it reads either n - 1 characters or a newline character whichever comes first. fgets retains the newline character at the end of s. A null byte is appended to s to mark the end of the string.
Return Value
On success fgets returns the string pointed to by s; it returns NULL on end-of-file or error.
hasafraggin shizigishin oppashigger...
I'm sorry.Originally posted by doubleanti
please use more descriptive post titles as it will help you get better answers. and try searching on your own first, even if your compiler's editor did not include a help reference for your standard library functions, there are many resources elsewhere.
I wanna know what does "fgets(y, sizeof(y), stdin);
" mean in below codes:
thx!!~Code:#include "stdio.h" void main() { char y[30]; printf("Enter a string : "); fgets(y, sizeof(y), stdin); printf("The input was : %s \n", y); return; }
>char *fgets(char *s, int n, FILE *stream);
>Description
>Gets a string from a stream.
In your code,
the string is called y
the stream is called stdin
Simply put, it reads a string from stdin
I guess you're really wondering what stdin is, well its normally your keyboard
Oh, one more thing
> void main()
should be int main ()
And
> return;
should be return 0;
Originally posted by Salem
>char *fgets(char *s, int n, FILE *stream);
>Description
>Gets a string from a stream.
In your code,
the string is called y
the stream is called stdin
Simply put, it reads a string from stdin
I guess you're really wondering what stdin is, well its normally your keyboard
Oh, one more thing
> void main()
should be int main ()
And
> return;
should be return 0;
I want to know why you think "main() should return an integer value "?
> I want to know why you think "main() should return an integer value "?
Try reading the language standard
http://anubis.dkuug.dk/JTC1/SC22/WG14/www/docs/n869/
oic, thx!!Originally posted by Salem
> I want to know why you think "main() should return an integer value "?
Try reading the language standard
http://anubis.dkuug.dk/JTC1/SC22/WG14/www/docs/n869/