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!