Hello,
I am trying to extract part of text in an array of char.
Below, I try to extract : "123.145.789.123", but the second step already does not work.
I am also confused between pointers, arrays, etc.
If anyone wants to explain to me, I'm interested.
Thank you.
You will have to increment t3 before the second step. After the first step, that first char is a comma. Next you use strstr and what will it find? The first character.
t3 = strstr(t1, t2);
Serial.print(t3); // j'obtiens biens : ,"www.truc.com","123.145.789.123"
// increment t3 so it points to the next character
t3++;
t3 = strstr(t3, t2);
Serial.println(t3);
If you're only looking for a single character, use strchr(). E.g.
t3 = strchr(t1, ',');
Serial.print(t3); // j'obtiens biens : ,"www.truc.com","123.145.789.123"
// increment t3 so it points to the net character
t3++;
t3 = strchr(t3, ',');
Serial.println(t3);
There is also the function strtok() which is usually used for parsing; it however is destructive in the sense that it destroys the input string.
// Note
t3++ increments the pointer, not the character that it points at.