I'm pretty new to C++ and having trouble with this simple code:
#include <iostream>
using namespace std;
int main() {
int NumberOfNonBlanks = 0;
int NumberOfUpperCase = 0;
char c;
while (cin >> c) {
++NumberOfNonBlanks;
if ((c>='A' && (c <= 'Z'))) {
++NumberOfUpperCase;
}
}
cout << "Nonblank characters : " << NumberOfNonBlanks << endl
<< "Uppercase characters : " << NumberOfUpperCase << endl;
}
My operating system is Windows, and Ctrl+D seems to exit the loop (Ctrl+Z isn't doing anything), but the problem is that it ends the whole program as well. Thus, my last line in the code isn't doing anything... For example if I put in input as:
BLUE
then press Ctrl+D, the program finishes immediately with return value 0.
Any help would be appreciated why this keeps happening. Thanks!
-------------EDIT-----------------
There has been some arguments that ctrl + z does not indicate EOF for CLion (operating on windows) at the moment. Does anyone know any solutions for CLion in this case?