What is the practical difference, if any, between stdin
and STDIN_FILENO
in C?
stdin : 1. A file pointer (* FILE) 2. The file descriptor table holds its address when process is created. 3. present in /usr/include/stdio.h
STDIN_FILENO : 1. It is a macro 2. Its nothing but an array index of a file descriptor table (default 0). 3.present in /usr/include/unistd.h
Could be more clear by following code.
#include
#include
int main()
{
printf("%d\t\t%p ----- ",STDIN_FILENO,stdin);
return 0;
}