In Unix system calls, standard input descriptors are used for stdin, standard output is stdout, standard error is expressed in stderr, but in some call functions, reference is made to the Stdin_fileno standard input, the same, standard access Stdout_fileno, Standard error with Stderr_fileno.
The difference between them:
stdin etc is the file * type, which belongs to standard I/O, in <stdio.h>.
Stdin_fileno, etc. are file descriptors, nonnegative integers, generally defined as 0, 1, 2, which belong to I/O without buffer, call system call directly in <unistd.h>.
The following example is applied to Stdout_fifeno and Stdin_fileno: #include <unistd.h> #define SIZE 100
int main (void) {int n; Char Buf[size];
while (N=read (stdin_fileno,buf,size)) //Read standard input to BUF, returns the number of bytes read. { if (N!=write Stdout_fileno , buf,n) BUF write to standard output perror ("WRI Te error "); &NBSP} if (n<0) perror ("read error"); return 0; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ If you follow the usual method of use: fan@fan:~/arm$ gcc-o App stdout.c fan@fan:~/arm$./app fdfe fdfe FEFEFEF//input line, immediately output a row, that is, the output is in the original FEFEFEF ============================================== uses redirects to run fan@fan:~/arm$ ./app> data fefe fdadfdf ADFDFEF// The input string is not output to the terminal, but is output to the data file. ========================================================================== fan@fan:~/arm$./app <stdout.c>data fan@fan:~/arm$ //This is the equivalent of copying stdout.c to data ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++= Stdout_fileno and Stdin_fileno are terminals by default, using Ctrl+d to enter file Terminator