stdin、stdout、stderrstdin, stdout, stderr

语法Syntax


      FILE *stdin;   
FILE *stdout;   
FILE *stderr;   
#include <stdio.h>  

备注Remarks

以下是输入、输出和错误输出的标准流。These are standard streams for input, output, and error output.

默认情况下,标准输入是从键盘读取的,而标准输出和错误输出将打印到屏幕。By default, standard input is read from the keyboard, while standard output and standard error are printed to the screen.

下列流指针可用于访问标准流:The following stream pointers are available to access the standard streams:

指针Pointer Stream
stdin 标准输入Standard input
stdoutstdout 标准输出Standard output
stderr 标准错误Standard error

这些指针可用作函数自变量。These pointers can be used as arguments to functions. 一些函数(如 getchar 和 putchar)将自动使用 stdin 和 stdout。Some functions, such as getchar and putchar, use stdin and stdout automatically.

这些指针是常量,无法分配新的值。These pointers are constants, and cannot be assigned new values. freopen 函数可用于将流重定向到磁盘文件或其他设备。The freopen function can be used to redirect the streams to disk files or to other devices. 操作系统使您可以在命令级别重定向程序的标准输入和输出。The operating system allows you to redirect a program's standard input and output at the command level.

请参阅See Also

流 I/O Stream I/O
全局常量Global Constants