How do you convert a String to a float or int?

后端 未结 5 1575
醉酒成梦
醉酒成梦 2021-02-19 03:56

In an Arduino program I\'m working on the GPS sends the coordinates to the arduino through USB. Because of this, the incoming coordinates are stored as Strings. Is there any way

5条回答
  •  逝去的感伤
    2021-02-19 04:47

    c_str() will give you the string buffer const char* pointer.
    .
    So you can use your convertion functions:.
    int gpslong = atoi(curLongitude.c_str())
    float gpslong = atof(curLongitude.c_str())

提交回复
热议问题