stdin is a file descriptor, representing standard input (keyboard, etc.), which means that in Linux, stdin is called the standard input of the terminal (Terminal).
In Linux, you often see stdin, stdout and stderr. These three can be called the standard input (standard input) and standard output (standard) of the terminal. out) and standard error output (standard error).
View the manual through man stdin, you can see that they are all defined in stdio.h. When Linux starts executing a program, the program will open these three file streams by default, so that input and output operations can be performed on the terminal.
The following uses c language to simulate the standard input (standard input) file stream.
Standard input (standard input)
is expressed in C language by calling the scanf function to accept user input, that is, input from the terminal device. You can also use fscanf to specify stdin to receive content. The file identifier for standard input is 0.
#include <stdio.h> intmain(void) { charstr[10]; scanf("%s", str); fscanf(stdin, "%s", str); return0; }
The above is the detailed content of What is stdin of linux?. For more information, please follow other related articles on the PHP Chinese website!