SOLVED error: invalid conversion from 'int' to 'const char*'

Hello,

I am having issues getting a function that i made to work. I got the compiler to move get through the function without any errors but later in the code when the function is called i get "error: invalid conversion from 'int' to 'const char*'" and "error: initializing argument 1 of 'String::String(const char*)'" So I am wondering what I am doing to cause these errors and what I need to do to fix them.

String line;
char buf[200]= "Ax=-209  Ay=5  Az=1116   |   Gx=7  Gy=0  Gz=7  |    -31   233   -433  Headings 100.20";

void setup()
{
  Serial.begin(57600);
  
}
  int getVal(String x,String y)//input sting and what value thats wanted from the string
{
   int s = x.indexOf(y,1);  //find location in string
   int e = x.indexOf(' ',s+4);  //extract the info
   String h = x.substring(s,e);
   int t = h.toInt();
   return t;
}


void parse(char buf[]) 
{
  line = String (buf);
  int xAxis = getVal(line,'Ax=');
  int yAxis = getVal(line,'Ay=');
  int ZAxis = getVal(line,'Az=');
  int xGxis = getVal(line,'Gx=');
  int YGxis = getVal(line,'Gy=');
  int zGxis = getVal(line,'Gz=');
}


void loop()
{
    
}

I get the errors when the compiler reaches "xAxis" If I am completely on the wrong track with this let me know. I am still really new at this.

try posting your whole code and the error messages (copied) from the IDE.

Mark

'Ax='

Is an integer, not a char* string.

Notice the difference between ' (single quote) and " (speech mark)

Why are you converting strings to Strings in the call to the function? Nothing that code is doing needs the String class. The strtok(), strcmp(), and atoi() functions would do the same work, faster, using less resources.

Thanks Tom that did the trick!
Paul I'm a newbie I will go check that stuff out but would not know where to begin with those commands. Would I use them in the same way that I use the commands that I am currently using?

Would I use them in the same way that I use the commands that I am currently using?

Yes, and no. They are not an exact substitution. Some research into what each one does will reveal how to use them, I'm sure.

You have tokens, separated by spaces or equal signs. Find all the tokens delimited by =, one at a time, until there are no more tokens or until you have found the correct one (as determined by strcmp()). Then, find the token delimited by a space, and use atoi() to convert it to an int.

Thank you PaulS.

Hydro42