C++ 流类结构
在 C++ 流 中指的是程序线程和 I/O 之间传输的字符流。
C++ 中的流类用于对文件和 I/O 设备进行输入和输出操作。这些类具有特定的功能来处理程序的输入和输出。
iostream.h 库 包含了 C++ 编程语言 中的所有流类。
让我们看看它们的层次结构并了解它们。

现在,让我们学习一下iostream库中的类。
ios 类 - 这个类是所有流类的基类。流可以是输入流或输出流。此类定义了独立于类模板定义方式的成员。
istream 类 - istream 类处理 C++ 编程语言中的输入流。这些输入流对象用于读取和解释输入作为一系列字符。cin 处理输入。
ostream 类 - ostream 类处理 C++ 编程语言中的输出流。这些输出流对象用于将数据作为一系列字符写入屏幕。cout 和 puts 处理 C++ 编程语言中的输出流。
示例
输出流
COUT
#include <iostream>
using namespace std;
int main(){
cout<<"This output is printed on screen";
}输出
This output is printed on screen
PUTS
#include <iostream>
using namespace std;
int main(){
puts("This output is printed using puts");
}输出
This output is printed using puts
输入流
CIN
#include <iostream>
using namespace std;
int main(){
int no;
cout<<"Enter a number ";
cin>>no;
cout<<"Number entered using cin is "<输出
Enter a number 3453 Number entered using cin is 3453
gets
#include <iostream>
using namespace std;
int main(){
char ch[10];
puts("Enter a character array");
gets(ch);
puts("The character array entered using gets is : ");
puts(ch);
}输出
Enter a character array thdgf The character array entered using gets is : thdgf
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP