Advertisement
Sinux1

Lab12.cpp

May 3rd, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream>
  2. #include <cctype>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int counter = 0;
  8.     string line;
  9.  
  10.     cout << "Enter a line of text\n";
  11.     getline(cin, line);
  12.  
  13.     for (int sub = 0; sub < line.length(); sub++)
  14.     {
  15.         if (ispunct(line[sub]))
  16.         {
  17.             counter++;
  18.         }
  19.     }
  20.     cout << "Punctuation character count: " << counter << endl;
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement