I tried the code I found here, the second one, but it doesn't work. Actually, during the execution I try to push 's' button but it doesn't save anything. I tried also to use breakpoints in debug mode, but never change the value of the variable char c. What happens?
I solved in the following manner. I substituted this code:
std::string c;
std::getline (std::cin,c);
std::string str2 ("s\n");
if( str2.compare(c)) {//as before}
to that provided:
c = getchar();
if( c == 's' ){}
With my solution it works well!