Coverting a message received in char buffer to integer

2017-04-21 11:45:59

I am receiving a message from my mobile to my microcontroller via GSM. The message in char buffer but i want to convert it to integer as i want to perform some mathematical operations ahead . I tried many functions such as atoi,toint but its not working. Please let me know if there is anyway in which i could do this conversion.

Please help asap

Thanks in advance

atoi() is the simplest way:

int val = atoi(buf);

If that doesn't work then your buffer doesn't start with the number you are after. If that is the case you will have to work out where in the buffer the number is and convert just that portion. How you do that depends on what the format of the data is in your buffer.

  • atoi() is the simplest way:

    int val = atoi(buf);

    If that doesn't work then your buffer doesn't start with the number you are after. If that is the case you will have to work out where in the buffer the number is and convert just that portion. How you do that depends on what the format of the data is in your buffer.

    2017-04-21 12:25:27