What is stdin of linux?

藏色散人
Release: 2020-09-18 16:27:24
Original
19073 people have browsed it

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;
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template