Shortest path string . What is wrong in using cin>>ch

#include
using namespace std;

int main() {
char ch ;
cin>>ch;
int x = 0;
int y = 0 ;

while (ch != '\n'){

    if(ch=='n'){
        x++ ;
    }
    else if (ch=='s'){
        x=x-1;
    }
    else if (ch=='e'){
        y++ ;
    }
    else {
        y = y-1 ;
    }
  
    cin>>ch;
}
cout<<x<<","<<y ;

return 0 ;
}

hello @sp_wizard
we cannot read delimiter (like space or newline characetr etc) using cin>>ch;

thats why we use cin.get() it reads one character at a time and it can also read delimiters

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.