📄 demo_3_io_function_3.cpp
字号:
//***************************************************
// 区别: 用流成员函数get或getline输入一行字符
//***************************************************
# include <iostream.h>
int main()
{
char ch[40];
cout<<"Enter a sentence: "<<endl;
cin>>ch; //遇到空格、tab键、回车键等分隔符结束输入
cout<<"The string read with cin is:"<<ch<<endl;
// cin.getline(ch,40,'/');
cin.get(ch,40,'/');
cout<<"The second part is:"<<ch<<endl;
// cin.getline(ch,40);
cin.get(ch,40);
cout<<"The third part is:"<<ch<<endl;
return 0;
}
/*
Enter a sentence:
I like C++./I study C++ very hard./I am happy.
The string read with cin is:I
The second part is: like C++.
The third part is:I study C++ very hard./I am happy.
Press any key to continue
*******************************************************
Enter a sentence:
I like C++./I study C++ very hard./I am happy.
The string read with cin is:I
The second part is: like C++.
The third part is:/I study C++ very hard./I am happy.
Press any key to continue
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -