0
Converting character digit into int type
How do i convert a character say char a[2] = "11" into integer type? (char a[2] ="11" - - - > int i =11)
4 Respostas
+ 11
(int) a[2]
+ 8
I don't think it's going to work the way you want it to. Casting an int value to char, and converting int values to their char counterparts is different.
You may be looking for something like this:
https://code.sololearn.com/czOgq2u6N5fc/?ref=app
+ 2
You mean to say, int i = (int) a[2]?
+ 1
@ValentinHacker That will not work in C++. When you cast an ASCII character to int, you will get the ascii code that represents that character, not the actual number