I have a char array that has '4''5'. But I want to convert those characters into actual integers so I subtract '0' from each index of the char array and store it into the same array. If I want to set an int called value to the 45 (the stuff inside the char array) How would I do it?
atoi() converts string to integer. For example if you already have the char array and integer variable declared you can do:
val = atoi(theCharArray);
int int_value;
int_value = atoi(your_char_array);
the atoi()
Function is used to convert string
to int
.
more information about atoi()
Here .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.