#include #include #include using namespace std; int main () { ifstream infile; int space_count = 0; int newline_count = 0; int normal_char = 0; int total_char = 0; char ch; infile.open("if.txt"); if (!infile) { cout << "Can not open file if.txt " << endl; return(-1); } infile.get(ch); while (infile) { if (' ' == ch) { space_count ++; } else if ('\n' == ch) { newline_count ++ ; } else { normal_char ++; } total_char ++; infile.get(ch); } cout << "There were " << setw(8) << total_char << " characters in that file" << endl; cout << "There were " << setw(8) << space_count << " spaces in that file" << endl; cout << "There were " << setw(8) << newline_count << " newlines in that file" << endl; cout << "There were " << setw(8) << normal_char << " other characters in that file" << endl; return(0); }