Good morning..
I want to convert char to int. What function can do this?
Regards.
Good morning..
I want to convert char to int. What function can do this?
Regards.
int my_num = (int)my_char;
FutureEngineer:
Good morning..I want to convert char to int. What function can do this?
Regards.
Is that a single char or a zero terminated array of chars (aka a C string) ?
char theChars[] = {"123"}; //automatically zero terminated
char aChar = '9';
int theInt;
void setup()
{
Serial.begin(115200);
Serial.println(theInt);
theInt = atoi(theChars);
Serial.println(theInt);
theInt = aChar - '0';
Serial.println(theInt);
}
void loop()
{
}
May I ask why you want or need to do it ?