K S*_*iel 51
这意味着您要在主输出设备上打印输出以进行会话......无论可能是什么.用户的控制台,tty会话,文件或谁知道什么.该设备可能会有所不同,具体取决于程序的运行方式和位置.
以下命令将写入标准输出设备(stdout)...
printf( "hello world\n" );
Run Code Online (Sandbox Code Playgroud)
从本质上讲,这只是另一种方式......
fprintf( stdout, "hello world\n" );
Run Code Online (Sandbox Code Playgroud)
在这种情况下,stdout是指向FILE表示应用程序的默认输出设备的流的指针.你也可以用
fprintf( stderr, "that didn't go well\n" );
Run Code Online (Sandbox Code Playgroud)
在这种情况下,你将被发送输出到标准误差输出装置的应用,其可能或可能不,是相同的stdout-与stdout,stderr是一个指针指向一个FILE表示用于错误消息的默认输出设备信息流.
aki*_*don 13
这取决于.
当您承诺发送输出时stdout,您基本上将其留给用户来决定输出应该去哪里.
如果您使用printf(...)(或等效fprintf(stdout, ...)),您将输出发送到stdout,但实际结束的位置取决于我如何调用您的程序.
如果我从我的控制台启动程序,我会在控制台上看到输出:
$ prog
Hello, World! # <-- output is here on my console
Run Code Online (Sandbox Code Playgroud)
但是,我可能会启动这样的程序,在控制台上不产生任何输出:
$ prog > hello.txt
Run Code Online (Sandbox Code Playgroud)
但我现在有一个文件"hello.txt",文字"Hello,World!" 在内部,感谢shell的重定向功能.
谁知道 - 我甚至可以连接其他设备,输出可以去那里.关键在于,当您决定打印stdout(例如通过使用printf())时,在您看到如何启动或使用该过程之前,您将无法准确知道它将在何处.
小智 6
stdout 是标准输出文件流。显然,它的第一个也是默认的输出指针是屏幕,但是您可以根据需要将其指向文件!
请阅读:
http://www.cplusplus.com/reference/cstdio/stdout/
C++ 与 C 非常相似,但都是面向对象的。
stdout是UNIX中的标准输出流。请参阅http://www.gnu.org/software/libc/manual/html_node/Standard-Streams.html#Standard-Streams。在终端中运行时,您将看到写入stdout终端的数据,并且您可以根据需要重定向它。
| 归档时间: |
|
| 查看次数: |
146841 次 |
| 最近记录: |