Possible Duplicate:
How to stop C++ console application from exiting immediately?
I'm using fstream to gather an input file from the user. Unfortunately, the console only displays briefly.
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;
I need to read every letter from the input file and do a number of checks on each of these characters. Why won't my console stay open?