125.C++输入小结

 1 #include <iostream>
 2 #include <iomanip>
 3 #include <cstring>
 4 #include <cstdlib>
 5 using namespace std;
 6 
 7 void main()
 8 {
 9 
10     /*char ch1, ch2, ch3;
11     cin.get(ch1).get(ch2).get(ch3);
12     cout.put(ch1).put(ch2);*/
13 
14     //char ch[20] = { 0 };
15     ////忽略一个字符
16     //cin.ignore();
17     //在读完的前提下,从当前位置一直到#结束这段字符都忽略了,最大长度是1024
18     //cin.ignore(1024, '#');
19     //设置最大极限
20     //cin.ignore(numeric_limits<streamsize>::max(), '#');
21     ////从某个地址写入20个字节的长度,预留一个'
22     //cin.get(ch,20);
23     //cout << ch << endl;
24 
25     char ch[30]{ 0 };
26     //从指定字符读取30个字符遇到s终止
27     cin.get(ch, 30, 's');
28     cout << ch << endl;
29     system("pause");
30 }
原文地址:https://www.cnblogs.com/xiaochi/p/8620166.html