if-statement checking a string with appended int

Hi everyone,

I have a basic question about strings:

In a sketch including some webserver things, I get the form result from the user by GET. I then have a string where the parameters are in the form /?param1=1&param2=0&param3=1&param4=1 etc.

Now I want to check in a loop for some params like this:

for (int i=1;i<5;i++){
if (parameterstring.indexOf("param"+i)!=-1 makeAction(i);
}

This isn’t working. The problem seems to be the concatenation of the string with the int. What’s wrong there?

Greetings,
greyhound

Untested but might get you somewhere:

for (int i=1;i<5;i++){
  char test[] = "param";
  char idx[2] = "x";
  idx[0] = i + '0';
  strcat(test,idx);
  if (parameterstring.indexOf(test)!=-1) {
    makeAction(i); //sure you do not want to extract the parameter value, not its index?
    //ie parameter1=2 would trigger makeAction(1) sure you do not want makeAction(2) ?
    //just a wild guess, good luck!
  }
}

thanks! works perfect...