注册 登录
编程论坛 C++教室

请教一个输入流的问题

hasohuang 发布于 2007-07-10 14:20, 573 次点击

以下是程序代码编译运行没有问题,但我想请问下,输入什么可以使程序结束?
谢谢!

#include<iostream>
#include<fstream>
#include<sstream>

using namespace std;

istream &ccc();

int main()
{
ofstream os;
ifstream os2;
ostringstream os1;

ccc();


system("PAUSE");
return 1;
}

istream &ccc()
{
char a;
while(cin>>a,!cin.eof())
{
if(cin.bad()){cout<<"error!end!"<<endl;break;}
else if(cin.fail()){cout<<"bad!end too!"<<endl;break;}
else cout<<a<<endl;
}
return cin;
}

8 回复
#2
aipb20072007-07-10 14:28
ctrl + z
#3
leeco2007-07-10 14:40
输入一个'
#4
leeco2007-07-10 14:42

#include <stdio.h>
int main()
{
printf("%c",-1);
}
把打印出来的像空格一样的东西复制下来,输入这个就行了。比输入^Z更有效。

#5
hasohuang2007-07-10 15:05
ctrl+z是结束不了的哦,我试过了
#6
hasohuang2007-07-10 15:08
但如果是输入CTRL+Z之后按enter再输入ctrl+z就可以了,为什么
#7
leeco2007-07-10 15:57
因为^Z和-1不等价,你按我说的做肯定立即结束
#8
aipb20072007-07-10 17:06
回复:(hasohuang)但如果是输入CTRL+Z之后按enter再...
因为你用的vc++6.0.
#9
野比2007-07-10 19:22
ctrl + break...Super DOS结束命令...
1