eof()

来源:互联网 发布:linux netstat -ano 编辑:程序博客网 时间:2024/05/21 09:42
#include <iostream>using namespace std;char GetChar(istream&in=cin)//从输入流in中跳过空格以获取一字符{char ch;int a=1;while(!in.eof()&&(ch=in.get())==' ');//先读取到文件结束符再结束return ch;}int main(){char ch;cout<<"请输入一行字符:"<<endl;ch=GetChar();while(ch!='%'&&ch!='\n'){//cout<<"1111"<<endl;cout.put(ch);ch=GetChar();}cout<<endl;system("PAUSE");return 0;}

0 0
原创粉丝点击