C++ do while loop to count characters
#include <iostream> int main()//w w w.j a v a2s . c o m { long count {}; char ch {}; std::cout << "Please enter a sequence of characters terminated by '#':" << std::endl; do { std::cin >> ch; ++count; } while (ch != '#'); // do not count '#' as a character --count; std::cout << "You entered characters (not counting spaces and the terminal #)." << std::endl; }