I have a smal piece of code that should convert a string containing a number, eg 179, to a number like 179000.
Thinking i could use atol constructed this routine:
unsigned long NewXaxis;
void readCommand(char character)
if (character == ',' || character == '\n' || character == '\r')
Serial << "Got a String" << endl;
if(readString.length() > 0)
Serial << "Received " << readString << endl;
readString += "0"; // make it 0 terminated
NewXaxis = atol(readString) * 1000;
Serial << "New X Axis " << NewXaxis << endl;
readString = "" ;
readString += character; //builds the string readString
I know that atol only can work with 0 terminated strings, so i added that ad the end of readString.
But wont compile saying:
error: cannot convert 'String' to 'const char*' for argument '1' to 'long int atol(const char*)'
Am i thinking to simple and if so how to solve this.