Pointers

Hi there

I have been looking at this for a while and I am just confused. I know it is some sort of problem with pointers but dont know how to solve it.

I have a function which I call which returns a String up to 60 chars long. The first char is a "*" and the last a "!". Commas separate different values inside the string. I have not completed the data handling part ie there are still more variables to add/extract from the string but this is my starting point. The problem I have is that I keep getting the following error -

"cannot convert 'String' to 'char*' for argument '1' to 'char* strok(char*, const char*)'"

I assume that there is some problem relating to pointers which the initial of where I begin to extract the data.

David

String pageValue = connectAndRead();

  humiditytemp = atof(strtok(pageValue, "*"));
  humidity = atoi(strtok(NULL, ","));
  dewpoint = atof(strtok(NULL, ","));
  pressure = atof(strtok(NULL, ","));
  lightlevel = atof(strtok(NULL, ","));
  1. Do NOT use the class String on the arduino's. Search this forum for threads on the topic.

  2. atoi() etc expect array of char / char* not the class String and there is not built in cast for this.

  3. String is a class, array of char is a string (lower case). Lower case string is not the same as Upper case String.

Mark

There doesn't seem to be any error handling in that code, so if you ever encounter a malformed string I suspect you're going to crash and burn.