golden是什么牌子| 血氧是什么| 埋伏牙是什么意思| 气血虚挂什么科| 代孕什么意思| ldl是什么意思| 922是什么星座| pla是什么意思| 眩晕吃什么药| 大口鱼是什么鱼| 人越来越瘦是什么原因| 梦见自己离婚是什么预兆| 肾上腺素有什么用| 80属什么| 哈尼是什么意思| 女性hpv阳性是什么意思| 塞屁股的退烧药叫什么| 存款到100万算什么阶层| 气血亏吃什么补的快| 蛇为什么怕鹅| 长期口臭吃什么药| 吃海参有什么好处| 3.2号是什么星座| 尿酸高看什么科| 健胃消食片什么时候吃最好| 蛟龙是什么意思| 黑色是什么颜色组成的| 婴儿出汗多什么原因| 落花流水什么意思| 什么样的伤口算开放性| 拉大便有血是什么原因| 什么动物最怕水| 低血压是什么原因引起的| 感康是什么| 肾阴虚的症状吃什么药| 舌尖发麻是什么病的前兆| 狗男和什么属相最配| 先明后不争什么意思| 肾炎的症状是什么| 高三学生吃什么补脑抗疲劳| 纺织厂是做什么的| 中国最早的文字是什么| 外面下着雨犹如我心血在滴什么歌| 羊水偏多对胎儿有什么影响| 手脚发胀是什么前兆| 养殖业什么最赚钱农村| 肉馅可以做什么美食| 没有鱼鳞的鱼是什么鱼| 冰箱双变频是什么意思| 胆固醇偏高吃什么食物可以降胆固醇| 什么品牌奶粉最好| 酒后吃什么解酒最快| 身上长红痣是什么原因| 37岁属什么的生肖| 胸小是什么原因| 喉咙扁桃体发炎吃什么药| 发动机抖动是什么原因| 弧度是什么意思| 反复口腔溃疡是什么原因| 硫磺有什么作用| 骨折和骨裂有什么区别| 肝郁症是什么病| 雷击木有什么作用| 白头发吃什么好| 经常流鼻血是什么病的前兆| 什么是医美| 屁股后面骨头疼是什么原因| 一个均一个金念什么| 脚心发凉是什么原因| 骨头咔咔响是什么原因| 1974年属什么| 卵胎生是什么意思| 天天想睡觉没精神是什么原因| 西瓜配什么榨汁好喝| 早孕有什么反应| 急性胃肠炎吃什么药| 西瓜汁加什么好喝| hcg什么时候查最准确| 梦见手表是什么意思| 头痒用什么洗头可以止痒| 一什么火焰| 碳酸盐质玉是什么玉| 一吃东西就肚子疼是什么原因| 血压为什么会高| 心血管堵塞吃什么好| 墨西哥说什么语言| 平板支撑练什么| 今年66岁属什么生肖的| 档案自由可投什么意思| 尿道口红肿是什么原因| 胎儿靠什么吸收营养| 什么是变应性鼻炎| 什么叫生化| parzin眼镜是什么牌子| 肠化什么意思| 补肾吃什么中药| 好难过这不是我要的结果什么歌| 取环挂什么科室| 枭印什么意思| 肠道炎有什么症状| 踏青是什么意思| 一路向北是什么意思| 烫伤忌口不能吃什么| 什么情况下需要根管治疗| 破瓜年华是什么意思| 身体机能是什么意思| 什么时候泡脚最好| 大姨妈来了不能吃什么水果| tct什么意思| 罗姓男孩取什么名字好| 冯巩什么军衔| 对什么有好处| 目赤什么意思| 什么颜色属水| 流理台是什么| 肺炎吃什么| 5.23是什么星座| 献血有什么坏处| 疏通血管吃什么药最好| 元旦唱什么歌| 仙草是什么草| 肚脐眼下面疼是什么原因| 左氧氟沙星治什么病| 精气是什么意思| 函询是什么意思| 被电击后身体会有什么后遗症| 肠癌吃什么好| 什么球不能踢| 吃什么长头发又密又多| 乳腺增生什么症状| 抽烟什么感觉| 梦见老鼠是什么征兆| 鼻子痒是什么原因| 生物膜是什么| 芹菜和西芹有什么区别| 吃什么长头发| 黑暗料理是什么意思| 患者是什么意思| 寻常疣是什么样子图片| 2016年属什么生肖| 1989年属什么的| 月经正常颜色是什么色| 连奕名为什么娶杨若兮| 眼皮浮肿是什么原因引起的| 赊账是什么意思| 大学休学1年有什么影响| 夏季吃桃子有什么好处| 什么样的小船| 糖尿病什么症状| 茶叶渣属于什么垃圾| 早搏吃什么药最管用| 朱砂痣代表什么| 什么是邪淫| 最好的止疼药是什么药| 股骨头坏死有什么症状| 做什么梦暗示你怀孕了| 不想怀孕有什么办法| 杨贵妃属什么生肖| 啄木鸟吃什么食物| 突然头昏是什么原因引起的| 顺势而为什么意思| 1130是什么星座| 在眼皮老跳是什么征兆| 地奥司明片治疗什么病| 火把节是什么节日| 猫毛过敏吃什么药| 唐塞是什么意思| 葛仙米是什么| 儿童办理身份证需要什么材料| 脱线是什么意思| 长时间憋尿会有什么影响| 土和什么相生| 黄皮果是什么水果| 女人喝劲酒有什么好处| 祥云是什么意思| 死精吃什么能调理成活精| 为什么做春梦| 1977年属蛇是什么命| 蛋白粉适合什么人群吃| 生忌是什么意思| 双侧乳腺腺病是什么意思| 味蕾是什么意思| 520是什么意思啊搞笑| 弹性工作制是什么意思| 婴儿蓝是什么颜色| 梦见马是什么预兆| 女人梦见火是什么预兆| 33朵玫瑰花代表什么意思| 灰喜鹊吃什么| 口腔溃疡吃什么药好得快| 囟门凹陷是什么原因| 12月14号是什么星座| 北极和南极有什么区别| 什么牛肉最好吃| 2月14日什么星座| 舌炎吃什么药效果最好| 勇气是什么意思| 怎么知道自己对什么过敏| 2023什么年| 牙龈上火是什么原因引起的| 习惯是什么意思| 女人喜欢什么姿势| 79年属什么生肖| 劳力士手表什么档次| 贵族是什么意思啊| uu解脲脲原体阳性是什么意思| 甲状腺1度肿大是什么意思| 淇字五行属什么| 足下生辉是什么意思| 淋巴结肿大是什么样子| 低压高吃什么中成药| stranger什么意思| 副巡视员是什么级别| 咳嗽吐黄痰吃什么药| 女人得性瘾什么症状| 孩子肚脐眼下面疼是什么原因| 1993属什么生肖| 胰头占位是什么病| 什么情况下要打狂犬疫苗| 10月19是什么星座| 心有灵犀是什么意思| 为什么小腹隐隐作痛| 检查甲亢挂什么科| 萎缩性胃炎不能吃什么食物| 银耳是什么| 智齿发炎肿痛吃什么药| 指甲横纹是什么原因| 后背长痘痘用什么药膏| 果实属于什么器官| 樱花什么时候开| 3.9是什么星座| 痰是绿色的是什么原因| 颜面扫地什么意思| 上眼皮突然肿了是什么原因| 中央候补委员什么级别| 绝经三年了突然又出血了什么原因| 青海古代叫什么| 杂面是什么面| 原位癌是什么意思| 淘宝什么时候有活动| 仓鼠可以吃什么蔬菜| 碱什么意思| 阳痿早泄挂什么科| 女人喜欢什么样的男人| 78是什么意思| 老年人吃什么钙片补钙好| 明年属相是什么生肖| 须发早白吃什么中成药| 男人的精子对女人有什么好处| 脑出血什么原因引起的| 金丝皇菊有什么功效| cha什么意思| 名媛什么意思| 拔得头筹是什么意思| 258是什么意思| 苹果手机为什么那么贵| 血小板高是什么病| 排卵期出血是什么原因造成的| 梦见偷别人东西是什么意思| 喝什么可以减肥瘦肚子| 调理肠胃吃什么好| 小腿肿胀是什么原因引起的| 肌钙蛋白高是什么意思| 女生痛经有什么办法缓解| 百度Jump to content

慢脚是什么

From Wikipedia, the free encyclopedia
(Redirected from Standard output)
百度 “IEEE1888发展至今,已在中国、日本、越南、泰国、印度等全球各国完成了多个成功的示范项目及商业化的解决方案,某些项目在帮助企业提高生产效率的同时,甚至产生了45%以上的节能量,并产生了很多新的商业机会及商业模式。

In computer programming, standard streams are preconnected input and output communication channels[1] between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin), standard output (stdout) and standard error (stderr). Originally I/O happened via a physically connected system console (input via keyboard, output via monitor), but standard streams abstract this. When a command is executed via an interactive shell, the streams are typically connected to the text terminal on which the shell is running, but can be changed with redirection or a pipeline. More generally, a child process inherits the standard streams of its parent process.

Application

[edit]
The standard streams for input, output, and error in a common default configuration

Users generally know standard streams as input and output channels that handle data coming from an input device, or that write data from the application. The data may be text with any encoding, or binary data. When a program is run as a daemon, its standard error stream is redirected into a log file, typically for error analysis purposes.

Streams may be used to chain applications, meaning that the output stream of one program can be redirected to be the input stream to another application. In many operating systems this is expressed by listing the application names, separated by the vertical bar character, for this reason often called the pipeline character. A well-known example is the use of a pagination application, such as more, providing the user control over the display of the output stream on the display.

Background

[edit]

In most operating systems predating Unix, programs had to explicitly connect to the appropriate input and output devices. OS-specific intricacies caused this to be a tedious programming task. On many systems it was necessary to obtain control of environment settings, access a local file table, determine the intended data set, and handle hardware correctly in the case of a punch card reader, magnetic tape drive, disk drive, line printer, card punch, or interactive terminal.

One of Unix's several groundbreaking advances was abstract devices, which removed the need for a program to know or care what kind of devices it was communicating with[citation needed]. Older operating systems forced upon the programmer a record structure and frequently non-orthogonal data semantics and device control. Unix eliminated this complexity with the concept of a data stream: an ordered sequence of data bytes which can be read until the end of file. A program may also write bytes as desired and need not, and cannot easily declare their count or grouping.

Another Unix breakthrough was to automatically associate input and output to terminal keyboard and terminal display, respectively, by default[citation needed] — the program (and programmer) did absolutely nothing to establish input and output for a typical input-process-output program (unless it chose a different paradigm). In contrast, previous operating systems usually required some—often complex—job control language to establish connections, or the equivalent burden had to be orchestrated by the program.[citation needed]

Since Unix provided standard streams, the Unix C runtime environment was obliged to support it as well. As a result, most C runtime environments (and C's descendants), regardless of the operating system, provide equivalent functionality.

Standard input (stdin)

[edit]

Standard input is a stream from which a program reads its input data. The program requests data transfers by use of the read operation. Not all programs require stream input. For example, the dir and ls programs (which display file names contained in a directory) may take command-line arguments, but perform their operations without any stream data input.

Unless redirected, standard input is inherited from the parent process. In the case of an interactive shell, that is usually associated with the input device of a terminal (or pseudo terminal) which is ultimately linked to a user's keyboard.

On POSIX systems, the file descriptor for standard input is 0 (zero); the POSIX <unistd.h> definition is STDIN_FILENO; the corresponding C <stdio.h> abstraction is provided via the FILE* stdin global variable. Similarly, the global C++ std::cin variable of type <iostream> provides an abstraction via C++ streams. Similar abstractions exist in the standard I/O libraries of practically every programming language.

Standard output (stdout)

[edit]

Standard output is a stream to which a program writes its output data. The program requests data transfer with the write operation. Not all programs generate output. For example, the file rename command (variously called mv, move, or ren) is silent on success.

Unless redirected, standard output is inherited from the parent process. In the case of an interactive shell, that is usually the text terminal which initiated the program.

The file descriptor for standard output is 1 (one); the POSIX <unistd.h> definition is STDOUT_FILENO; the corresponding C <stdio.h> variable is FILE* stdout; similarly, the C++ <iostream> variable is std::cout.

Standard error (stderr)

[edit]

Standard error is another output stream typically used by programs to output error messages or diagnostics. It is a stream independent of standard output and can be redirected separately.

This solves the semi-predicate problem, allowing output and errors to be distinguished, and is analogous to a function returning a pair of values – see Semipredicate problem § Multivalued return. The usual destination is the text terminal which started the program to provide the best chance of being seen even if standard output is redirected (so not readily observed). For example, output of a program in a pipeline is redirected to input of the next program or a text file, but errors from each program still go directly to the text terminal so they can be reviewed by the user in real time.

It is acceptable and normal to direct standard output and standard error to the same destination, such as the text terminal. Messages appear in the same order as the program writes them, unless buffering is involved. For example, in common situations the standard error stream is unbuffered but the standard output stream is line-buffered; in this case, text written to standard error later may appear on the terminal earlier, if the standard output stream buffer is not yet full.

The file descriptor for standard error is defined by POSIX as 2 (two); the <unistd.h> header file provides the symbol STDERR_FILENO;[2] the corresponding C <stdio.h> variable is FILE* stderr. The C++ <iostream> standard header provides two variables associated with this stream: std::cerr and std::clog, the former being unbuffered and the latter using the same buffering mechanism as all other C++ streams.

Bourne-style shells allow standard error to be redirected to the same destination that standard output is directed to using

 2>&1

csh-style shells allow standard error to be redirected to the same destination that standard output is directed to using

 >&

Standard error was added to Unix in the 1970s after several wasted phototypesetting runs ended with error messages being typeset instead of displayed on the user's terminal.[3]

Timeline

[edit]

1950s: Fortran

[edit]

Fortran has the equivalent of Unix file descriptors: By convention, many Fortran implementations use unit numbers UNIT=5 for stdin, UNIT=6 for stdout and UNIT=0 for stderr. In Fortran-2003, the intrinsic ISO_FORTRAN_ENV module was standardized to include the named constants INPUT_UNIT, OUTPUT_UNIT, and ERROR_UNIT to portably specify the unit numbers.

! FORTRAN 77 example
      PROGRAM MAIN
        INTEGER NUMBER
        READ(UNIT=5,*) NUMBER
        WRITE(UNIT=6,'(A,I3)') ' NUMBER IS: ',NUMBER
      END
! Fortran 2003 example
program main
  use iso_fortran_env
  implicit none
  integer :: number
  read (unit=INPUT_UNIT,*) number
  write (unit=OUTPUT_UNIT,'(a,i3)') 'Number is: ', number
end program

1960: ALGOL 60

[edit]

ALGOL 60 was criticized for having no standard file access.[citation needed]

1968: ALGOL 68

[edit]

ALGOL 68's input and output facilities were collectively referred to as the transput.[4] Koster coordinated the definition of the transput standard. The model included three standard channels: stand in, stand out, and stand back.

Example
# ALGOL 68 example #
main:(
  REAL number;
  getf(stand in,($g$,number));
  printf(($"Number is: "g(6,4)"OR "$,number)); # OR #
  putf(stand out,($" Number is: "g(6,4)"!"$,number));
  newline(stand out)
)
Input: Output:
3.14159
Number is: +3.142 OR Number is: +3.142!

1970s: C and Unix

[edit]

In the C programming language, the standard input, output, and error streams are attached to the existing Unix file descriptors 0, 1 and 2 respectively.[5] In a POSIX environment the <unistd.h> definitions STDIN_FILENO, STDOUT_FILENO or STDERR_FILENO should be used instead rather than magic numbers. File pointers stdin, stdout, and stderr are also provided.

Ken Thompson (designer and implementer of the original Unix operating system) modified sort in Version 5 Unix to accept "-" as representing standard input, which spread to other utilities and became a part of the operating system as a special file in Version 8. Diagnostics were part of standard output through Version 6, after which Dennis M. Ritchie created the concept of standard error.[6]

1995: Java

[edit]

In Java, the standard streams are referred to by System.in (for stdin), System.out (for stdout), and System.err (for stderr).[7]

public static void main(String args[]) {
    try {
        BufferedReader br = 
          new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        double number = Double.parseDouble(s);
        System.out.println("Number is:" + number);
    } catch (Exception e) {
        System.err.println("Error:" + e.getMessage());
    }
}

2000s: .NET

[edit]

In C# and other .NET languages, the standard streams are referred to by System.Console.In (for stdin), System.Console.Out (for stdout) and System.Console.Error (for stderr).[8] Basic read and write capabilities for the stdin and stdout streams are also accessible directly through the class System.Console (e.g. System.Console.WriteLine() can be used instead of System.Console.Out.WriteLine()).

System.Console.In, System.Console.Out and System.Console.Error are System.IO.TextReader (stdin) and System.IO.TextWriter (stdout, stderr) objects, which only allow access to the underlying standard streams on a text basis. Full binary access to the standard streams must be performed through the System.IO.Stream objects returned by System.Console.OpenStandardInput(), System.Console.OpenStandardOutput() and System.Console.OpenStandardError() respectively.

// C# example
public static int Main(string[] args)
{
    try {
        string s = System.Console.In.ReadLine();
        double number = double.Parse(s);
        System.Console.Out.WriteLine("Number is: {0:F3}", number);
        return 0;

    // If Parse() threw an exception
    } catch (ArgumentNullException) { 
        System.Console.Error.WriteLine("No number was entered!");
    } catch (FormatException) {
        System.Console.Error.WriteLine("The specified value is not a valid number!");
    } catch (OverflowException) {
        System.Console.Error.WriteLine("The specified number is too big!");
    }

    return -1;
}
' Visual Basic .NET example

Public Function Main() As Integer
    Try
        Dim s As String = System.Console.[In].ReadLine()
        Dim number As Double = Double.Parse(s)
        System.Console.Out.WriteLine("Number is: {0:F3}", number)
        Return 0

    ' If Parse() threw an exception
    Catch ex As System.ArgumentNullException
        System.Console.[Error].WriteLine("No number was entered!")
    Catch ex2 As System.FormatException
        System.Console.[Error].WriteLine("The specified value is not a valid number!")
    Catch ex3 As System.OverflowException
        System.Console.[Error].WriteLine("The specified number is too big!")
    End Try

    Return -1
End Function

When applying the System.Diagnostics.Process class one can use the instance properties StandardInput, StandardOutput, and StandardError of that class to access the standard streams of the process.

2000 - : Python (2 or 3)

[edit]

The following example, written in Python, shows how to redirect the standard input both to the standard output and to a text file.

#!/usr/bin/env python
import sys
# Save the current stdout so that we can revert sys.stdout
# after we complete our redirection
stdin_fileno = sys.stdin
stdout_fileno = sys.stdout
# Redirect sys.stdout to the file
sys.stdout = open("myfile.txt", "w")
ctr = 0
for inps in stdin_fileno:
    ctrs = str(ctr)
    # Prints to the redirected stdout ()
    sys.stdout.write(ctrs + ") this is to the redirected --->" + inps + "\n")
    # Prints to the actual saved stdout handler
    stdout_fileno.write(ctrs + ") this is to the actual  --->" + inps + "\n")
    ctr = ctr + 1
# Close the file
sys.stdout.close()
# Restore sys.stdout to our old saved file handler
sys.stdout = stdout_fileno

GUIs

[edit]

Graphical user interfaces (GUIs) do not always make use of the standard streams; they do when GUIs are wrappers of underlying scripts and/or console programs, for instance the Synaptic package manager GUI, which wraps apt commands in Debian and/or Ubuntu. GUIs created with scripting tools like Zenity and KDialog by KDE project[9] make use of stdin, stdout, and stderr, and are based on simple scripts rather than a complete GUI programmed and compiled in C/C++ using Qt, GTK, or other equivalent proprietary widget framework.

The Services menu, as implemented on NeXTSTEP and Mac OS X, is also analogous to standard streams. On these operating systems, graphical applications can provide functionality through a system-wide menu that operates on the current selection in the GUI, no matter in what application.

Some GUI programs, primarily on Unix, still write debug information to standard error. Others (such as many Unix media players) may read files from standard input. Popular Windows programs that open a separate console window in addition to their GUI windows are the emulators pSX and DOSBox.

GTK-server can use stdin as a communication interface with an interpreted program to realize a GUI.

The Common Lisp Interface Manager paradigm "presents" GUI elements sent to an extended output stream.

See also

[edit]

References

[edit]
  1. ^ D. M. Ritchie, "A Stream Input-Output System", AT&T Bell Laboratories Technical Journal, 68(8), October 1984.
  2. ^ "<unistd.h>". The Open Group Base Specifications Issue 6—IEEE Std 1003.1, 2004 Edition. The Open Group. 2004.
  3. ^ Johnson, Steve (2025-08-14). "[TUHS] Graphic Systems C/A/T phototypesetter" (Mailing list). Archived from the original on 2025-08-14. Retrieved 2025-08-14.
  4. ^ "Revised Report on the Algorithmic Language Algol 68", edited by A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck, C.H.A. Koster, M. Sintzoff, C.H. Lindsey, L.G.L.T. Meertens and R.G. Fisker, Section 10.3.
  5. ^ "Stdin(3): Standard I/O streams - Linux man page". die.net. Archived from the original on Jun 8, 2023.
  6. ^ McIlroy, M. D. (1987). A Research Unix reader: annotated excerpts from the Programmer's Manual, 1971–1986 (PDF) (Technical report). CSTR. Bell Labs. 139. Archived (PDF) from the original on Dec 15, 2023.
  7. ^ "System (Java Platform SE 7)". Oracle Help Center. Retrieved 20 July 2012.
  8. ^ ".NET Framework 4.7.1, mscorlib, console.cs". Reference Source - Microsoft. Archived from the original on Dec 10, 2017. Retrieved 2025-08-14.
  9. ^ Ki?ling, Kristian (2009). "Adding graphic elements to your scripts with Zenity and KDialog". Linux Magazine. Retrieved 2025-08-14.

Sources

[edit]
[edit]
欢是什么动物 舍本逐末什么意思 singing是什么意思 白加黑是什么药 宝宝尿少是什么原因
褒义词和贬义词是什么意思 脂溢性皮炎是什么引起的 牙齿酸是什么原因 前白蛋白是什么意思 幡然醒悟是什么意思
抑郁吃什么药可以缓解情绪 晚上11点多是什么时辰 尿酸高有什么症状 满城尽带黄金甲是什么意思 嘴里苦是什么原因
网贷是什么 降血压吃什么药 学考成绩什么时候公布 ad是补什么的 亚甲减是什么意思
桃胶是什么东西hcv9jop0ns3r.cn 九月九日是什么节日hcv9jop0ns2r.cn 三点水弘读什么hcv9jop0ns7r.cn 七月有什么节luyiluode.com 张国荣为什么喜欢男的hcv8jop5ns2r.cn
皇帝为什么自称朕hcv9jop5ns5r.cn 突然头晕冒虚汗什么原因hlguo.com 猫咪能吃什么水果hcv7jop6ns0r.cn 血管属于什么组织bjhyzcsm.com 头孢全名叫什么hcv7jop7ns3r.cn
木糖醇是什么东西hcv8jop9ns0r.cn 蝉是什么生肖hcv7jop6ns1r.cn 为什么会真菌感染hcv9jop6ns1r.cn 玉皇大帝姓什么hcv9jop1ns0r.cn 新百伦属于什么档次hcv8jop4ns9r.cn
早上打嗝是什么原因呢hcv8jop5ns9r.cn 康五行属什么hcv9jop2ns3r.cn 礻字旁与什么有关hcv9jop8ns0r.cn mct是什么hcv8jop8ns2r.cn 蓝加红是什么颜色tiangongnft.com
百度