Not able to understand cin.get() function

#include
using namespace std;
int main()
{
int x=0,y=0;
char ch;
cin>>ch;
while(ch!=’\n’)
{
if(ch==‘n’)
y++;
else if(ch==‘s’)
y–;
else if(ch==‘e’)
x++;
else if(ch==‘w’)
x–;
cin>>ch;
}
cout<<x<<" “<<y<<” are the required coordinates";
return 0;
}

why my code is not working if i dont use cin.get() and simply take char as input,please make me understand

@namangarg31 hey, cin.get() is used for accessing character array. It includes white space characters. Generally, cin with an extraction operator (>>) terminates when whitespace is found. However, cin.get() reads a string with the whitespace.

Syntax:
cin.get(string_name, size);

Example 1:
#include
using namespace std;
int main()
{
char name[25];
cin.get(name, 25);
cout << name;
return 0;
}
Input:
Geeks for Geeks
Output:
Geeks for Geeks

Example 2:
#include
using namespace std;

int main()
{
char name[100];
cin.get(name, 3);
cout << name;

return 0; 

}
Input:
GFG
Output:
GF
Sp basically it take spaces also ,therefore we used this.

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.