【发布时间】:2012-12-18 13:24:27
【问题描述】:
可能重复:
How to stop C++ console application from exiting immediately?
我正在使用 fstream 从用户那里收集输入文件。不幸的是,控制台只是短暂显示。
string filename;
cout << "input file" << endl ;
getline(cin,filename);
ifstream inputfile;
inputfile.open(filename);
char file_character ;
int counter = 0;
while (inputfile>> file_character) {
inputfile.get(file_character);
cout << file_character;
//not what I'm totally doing but instead a quick example
if (file_character == 'a')
{
counter++;
}
}
cout << counter << endl;
inputfile.close();
return 0;
我需要读取输入文件中的每个字母并对每个字符进行多次检查。为什么我的控制台无法保持打开状态?
【问题讨论】:
-
你在使用 Windows 吗?
-
你永远不会检查任何东西。如果你不能打扰,我们应该如何找出问题所在?