Hi Guys,
The 3rd parameter in fgets is expecting a pointer to a file.Code:fgets(buf,5,stdin);
When we want to get a safe input from the user to a buffer we use stdin instead.
What is "stdin"?
Where doe's it point to?
THANK YOU!
Hi Guys,
The 3rd parameter in fgets is expecting a pointer to a file.Code:fgets(buf,5,stdin);
When we want to get a safe input from the user to a buffer we use stdin instead.
What is "stdin"?
Where doe's it point to?
THANK YOU!
stdin is a "predefined" FILE * variable, declared in stdio.h.
It is the "standard input", which is normally your "console" [e.g what you type on the keyboard]. Or if you use redirection such as "myprog < somefile" it can be a file as input.
You should, in normal applications, never need to open or close stdin.
There are also two standard output channels:
stdout - normally your console, but is sometimes redirected to an output file, e.g. "myprog > somefile".
stderr - a second channel that is normally connected to the console. This is meant to show error and information to the user. It is very rarely redirected, so if your application is writing on stdout that is redirected, messages to stderr will normally show up on the console anyways.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Thank you it make sense now