I'm working on a C++ program that takes a string as an input and manipulates it in certain ways. This is the code:
string input;
cin >> input;
char arg = input[4]; //All inputs always have 5 characters
cout << arg << endl;
Input: add d
I was expecting it to print d to the screen but instead nothing is printed Also, for other inputs, I sometimes get weird characters (like y with two dots over it) as the output.
Why is this happening and how can it be rectified?