Home  >  Article  >  Operation and Maintenance  >  What is stdin of linux?

What is stdin of linux?

藏色散人
藏色散人Original
2019-05-20 16:49:3418925browse

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).

What is stdin of linux?

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn