#include iostream 在 C 中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1844223/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
#include iostream in C?
提问by neuromancer
In C++ we always put the following at the top of the program
在 C++ 中,我们总是将以下内容放在程序的顶部
#include <iostream>
What about for C?
对于 C 呢?
回答by AraK
Well, this is called the standard I/O header. In C you have:
嗯,这称为标准 I/O 标头。在 C 你有:
#include <stdio.h>
It's not an analog to <iostream>
. There is no analog to iostream in C -- it lacks objects and types. If you're using C++, it's the analog to <cstdio>
.
它不是<iostream>
. C 中没有与 iostream 类似的东西——它缺少对象和类型。如果您使用的是 C++,则它类似于<cstdio>
.
See also this fantastic question and its answer,
另请参阅这个奇妙的问题及其答案,
回答by danielv
#include <stdio.h>
回答by Fred
iostream is a C++ library for input-output. The C equivalent would be stdio.h
iostream 是一个用于输入输出的 C++ 库。C 等效项是 stdio.h
回答by Vivek
#include <stdio.h>
C Standard Input and Output Library (cstdio, known as stdio.h in the C language). This library uses what are called streams to operate with physical devices such as keyboards, printers, terminals or with any other type of files supported by the system. Streams are an abstraction to interact with these in an uniform way; All streams have similar properties independently of the individual characteristics of the physical media they are associated with.
C 标准输入输出库(cstdio,C 语言中称为 stdio.h)。该库使用所谓的流来操作物理设备,例如键盘、打印机、终端或系统支持的任何其他类型的文件。流是一种以统一方式与这些交互的抽象;所有流都具有类似的属性,独立于它们所关联的物理媒体的各个特性。
Streams are handled in the cstdio library as pointers to FILE objects. A pointer to a FILE object uniquely identifies a stream, and is used as a parameter in the operations involving that stream.
流在 cstdio 库中作为指向 FILE 对象的指针进行处理。指向 FILE 对象的指针唯一标识一个流,并在涉及该流的操作中用作参数。
There also exist three standard streams: stdin, stdout and stderr, which are automatically created and opened for all programs using the library.
还存在三个标准流:stdin、stdout 和 stderr,它们是为使用该库的所有程序自动创建和打开的。
回答by Vivek
In C :
在 C 中:
#include<stdio.h>
+ #include<stdlib.h>
to get the almost all functionality of <iostream>
#include<stdio.h>
+#include<stdlib.h>
获得几乎所有的功能<iostream>
For example there is system()
function (for windows only) in <iostream>
but not in <stdio.h>
.
例如,有system()
函数(仅适用于 Windows),<iostream>
但在<stdio.h>
.