Stream object cin
cin >> i;
// extract an integer from the input stream object cin at a time
cin.ignore (n); // Ignore the previous n characters
cin.getline (a, m, 'n'); // Receive the m characters of the a string, stop when the character n
#include<iostream>
using namespace std;
int main()
{
char buf[20];
cin.ignore(7);
cin.getline(buf,10,'5');
cout<<buf<<endl;
}
Input: 12222222354
Output: 23
cin.peek (); // The return value is a char character
cin.get (); // Receive a line of string or a character
cin.get(ch,10);//接收ch字符串的前十个
cin.get(ch);接收ch的第一个
cin.gcount();//
cin.read();//
#include<iostream>
using namespace std;
int main()
{
const int i=50;
char buf[i];
cout<<"输入文本:";
cin.read(buf,20);
cout<<"字符串收集到的字符数为:"<<cin.gcount()<<endl;
cout<<"输入的文本信息是:";
cout.write(buf,20);
cout<<endl;
return 0;
}
Input text: ahhhhhhhhhhhhhhhhhhhhhhhhhh The
number of characters collected by the string is: 20
The text information entered is: ahhhhhhhhhhhhhhhhhhhh