Hello, I have array of chars and I need parse this array. Array start and ends with unimportant characters.
I need find "btn1=1" or "btn1=0" and save value to boolean btn1 and so on... Sha1 is always 40 chars long.
At the end I need copy all important chars (bold text) to my new array allParams.
Input is always same. Only number is different (btn1=1"/"btn1=0") and sha hash is different.
I try:
#include <string.h>
void setup() {
Serial.begin(9600);char input[] = {"some unimportant \n databtn1=1&btn2=0&sha1=a5b5da1c91aa2ea0c7e630db6c8e3175058e907f some\t unimportant \ndata"};
boolean btn1;
boolean btn2;
char sha1[40];
char allParams[100];char tmp[6];
if ( strncpy(tmp, strstr(input,"btn1=1"), 6 ) )
btn1 = true;
if ( strncpy(tmp, strstr(input,"btn1=0"), 6 ) )
btn1 = false;
Serial.println(btn1);
}
void loop() {}
but it doesn't work. Can you help me, please?