- #include <iostream>
- using namespace std;
- int main( )
- {
- char c;
- while(!cin.eof( )) //eof( )为假表示未遇到文件结束符
- if((c=cin.get( ))!=' ') //检查读入的字符是否为空格字符
- cout.put(c);
- return 0;
- }
- #include <iostream>
- using namespace std;
- int main( )
- {
- char c[20];
- int ch;
- cout<<"please enter a sentence:"<<endl;
- cin.getline(c,15,'/');
- cout<<"The first part is:"<<c<<endl;
- ch=cin.peek( ); //观看当前字符
- cout<<"The next character(ASCII code) is:"<<ch<<endl;
- cin.putback(c[0]); //将'I'插入到指针所指处
- cin.getline(c,15,'/');
- cout<<"The second part is:"<<c<<endl;
- return 0;
- }
- #include <iostream>
- using namespace std;
- int main( )
- {
- char ch[20];
- cin.get(ch,20,'/');
- cout<<"The first part is:"<<ch<<endl;
- cin.get(ch,20,'/');
- cout<<"The second part is:"<<ch<<endl;
- return 0;
- }
- #include <iostream>
- using namespace std;
- int main( )
- {
- char ch[20];
- cin.get(ch,20,'/');
- cout<<"The first part is:"<<ch<<endl;
- cin.ignore( );//跳过输入流中一个字符
- cin.get(ch,20,'/');
- cout<<"The second part is:"<<ch<<endl;
- return 0;
- }
联系客服