hello i have a problem i am trying to convert a string like “12314234” to int
so i will get the first number in the string.
from the example of string that is shown above i want to get ‘1’ in int.
i tried :
string line = "12314234";
int command = line.at(0);
but it puts inside command the ascii value of 1 and not the number 1.
thanks in advance.
hello i have a problem i am trying to convert a string like 12314234
Share
To convert a numerical character (‘
0‘ – ‘9‘) to its corresponding value, just substract the ASCII code of ‘0‘ from the result.