// File: CntBlPer.cpp // COUNTS THE NUMBER OF BLANKS IN EACH LINE OF A FILE #include int main () { // Local data ... const char blank = ' '; // character being counted const char nwln = '\n'; // newline character char next; // next character in current line int blank_count; // number of blanks in current line int line_count; // keeps track of number of lines in file line_count = 0; cin.get (next); // get first char of new line while (!cin.eof ()) { blank_count = 0; // initialize blank count for new line while (next != nwln) { cout.put (next); if (next == blank) blank_count++; // increment blank count. cin.get (next); // get next character. } // end inner while cout.put (nwln); // marks end of current display line line_count++; cout << "The number of blanks is " << blank_count << "." << endl; cin.get (next); // get next character. } // end outer while cout << "The number of lines processed is " << line_count << "." << endl; return 0; }