What is the practical difference, if any, between stdin and STDIN_FILENO in C?
On program startup, the integer file descriptors associated with the streams stdin, stdout, and stderr are 0, 1, and 2, respectively. The preprocessor symbols STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO are defined with these values in <unistd.
STDIN_FILENO. Standard input value, stdin. Its value is 0.
The standard input device, also referred to as stdin , is the device from which input to the system is taken. Typically this is the keyboard, but you can specify that input is to come from a serial port or a disk file, for example.
Short for standard input, stdin is an input stream where data is sent to and read by a program. It is a file descriptor in Unix-like operating systems, and programming languages, such as C, Perl, and Java.
The interface.  Like everyone else has said, stdin is a FILE * as defined by the standard c library.  You can use some of the higher level interfaces like fread, fwrite, and fprintf.  On the other hand, STDIN_FILENO is just a file descriptor (almost certainly 0).  This uses a slight lower level interface through the likes of read and write.
stdin is a default FILE pointer used to get input from none other than standard in.
STDIN_FILENO is the default standard input file descriptor number which is 0.  It is essentially a defined directive for general use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With