当前位置: 首页 > 工具软件 > Peek.js > 使用案例 >

peek函数的用法

皇甫才良
2023-12-01
 1 #include <iostream>
 2 
 3 /* run this program using the console pauser or add your own getch, system("pause") or input loop */
 4 using namespace std;
 5 int main(int argc, char** argv) {
 6     char c[20];
 7     int ch;
 8     cout<<"please enter a sentence:"<<endl;
 9     cin.getline(c,15,'/');
10     cout<<"The first part is:"<<c<<endl;
11     ch=cin.peek();
12     cout<<"The next character(ASCII code) is:"<<ch<<endl;
13     cin.putback(c[0]);
14     cin.getline(c,15,'/');
15     cout<<"The second part is:"<<c<<endl;
16     return 0;
17 }

 

转载于:https://www.cnblogs.com/borter/p/9405553.html

 类似资料: