[SOLVED]How concat string and int to char?

Hello.

how i can concat, Strings and int, into char?

I have chars with:

url: "POST /arduino/save.php";

host: " HTTP/1.1\r\nHost: xx.xx.xx.xx\r\nred=1&green=0&blue=0\r\nConnection: close\r\n\r\n";

and concat into aux_str.

but need change this part: red=1&green=0&blue=0
for a variable composed by string and int.

Somethign like this:

int valred = red==HIGH ? '1' : '0'; //= this is like to digitalread, i think.

string red = "red";

int valgreen = green==HIGH ? '1' : '0'; //= this is like to digitalread, i think.

string red = "green";

int valblue = blue==HIGH ? '1' : '0'; //= this is like to digitalread, i think.

string red = "blue";

varleds = red=1&green=1&blue=1

char url[50] = "GET /arduino/getstate.php?color=All";         //Solo necesito las ordenes

char host[100] = " HTTP/1.1\r\nHost: xx.xx.xx.xx";

char host2[100] = "\r\nConnection: close\r\n\r\n";

strcat(url, host);

strcat(url, varleds);

strcat(url,host2);

thx very much ^^

try using sprintf ... something like

char s [100];
sprintf (s, "red=%d&green=%d&blue=%d", valred, valgreen, valblue);

What’s wrong with a simple sequence of prints?

A more complicated example using snprintf()

void setup()
{
  char buffer[100];  //somewhere to store the result
  int red = 1;
  int green = 2;
  int blue = 3;
  Serial.begin(115200);
  while (!Serial);
  snprintf(buffer, 99, "HTTP/1.1\\r\\nHost: xx.xx.xx.xx\\r\\nred=%d&green=%d&blue=%d\\r\\nConnection: close\\r\\n\\r\\n", red, green, blue);
  Serial.println(buffer);
  red = 123;
  green = 321;
  green = 255;
  snprintf(buffer, 99, "HTTP/1.1\\r\\nHost: xx.xx.xx.xx\\r\\nred=%d&green=%d&blue=%d\\r\\nConnection: close\\r\\n\\r\\n", red, green, blue);
  Serial.println(buffer);
}

void loop()
{
}

Note the use of \ to print a single backslash and the length parameter in snprintf()

Finally ^^

i use that:

  memset(valDatos, '\0', 100);
  valnMin = digitalRead(nMin);
  valnN1 = digitalRead(nN1);
  valnN2 = digitalRead(nN2);
  valnMax = digitalRead(nMax);
  valnAlarma = digitalRead(nAlarma);
  valestadoB1 = digitalRead(estadoB1);
  valestadoB2 = digitalRead(estadoB2);
  
  sprintf (valDatos, "valnMin=%d&valnN1=%d&valnN2=%d&valnMax=%d&valnAlarma=%d&valestadoB1=%d&valestadoB2=%d", 
  valnMin, valnN1, valnN2, valnMax, valnAlarma, valestadoB1, valestadoB1);

Thx very much guys ^^

What’s wrong with a simple sequence of prints?