invalid conversion from 'char*' to 'char' f permessive

hi
i have problem in the function strchr() in this code

float recherche(char code,float val) {
char ptr=buffer; // start at the beginning of buffer
while((long)ptr > 1 && (long)ptr < (long)buffer+taille) { // walk to the end
if(ptr==code) { // if you find code on your walk,
return atof(ptr+1); // convert the digits that follow into a float and return it
}
ptr=strchr(ptr,' ')+1; // take a step from here to the letter after the next space
}
return val; // end reached, nothing found, return default val.
}

i'm grateful for your help

while((long)ptr > 1 && (long)ptr < (long)buffer+taille) { // walk to the end

Why are you casting ptr to a long, when:

  1. It is NOT a pointer
  2. It is a char
    ?

Make ptr a pointer! Do NOT cast it.

how
could you explain more ?

how
could you explain more ?

char *ptr = buffer;
while(ptr > 1 &&  ptr < buffer+taille) {  // walk to the end

However, this will have problems, too. It doesn't make sense to compare a pointer to an absolute value.

Explain what you are trying to do, if you want us to help you. It looks like you are trying to re-implement strchr().

i want to create a function that search a specific caracter in a Gcode especially commands like"M" & "G" get,convert and return the digit that follow

So, use strchr() to locate the character, and just one at the next position.