Reputation: 93
I was wondering if there is a way to convert from a string object into a char. For example:
string str = "b";
char ch = //convert str to char
Any help would be appreciated. Thanks.
Upvotes: 0
Views: 288
Reputation: 2038
You can directly index the string to get the character you want in a same way you index simple arrays.
char ch = str[0];
This will work for you..
Upvotes: 1