char char_array_value[8];
char* txt;
char *msg;
char char_array_number[8];
char char_array_number_temp1[8];
char char_array_number_temp2[8];
int int_number;
int int_number_2;
char char_path[30];
char char_MacAddressWiFi[18];
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Programm Start");
//------------------------------------------------------
//1st approach to load value to string using C string.h functions:
strcpy(char_array_value,"cheers");
Serial.println(char_array_value);
//------------------------------------------------------
//2nd approach to load value to string using C string.h functions:
sprintf(char_array_value,"hello");
Serial.println(char_array_value);
//------------------------------------------------------
txt = "bye";
Serial.println(txt);
//------------------------------------------------------
msg = "thanks";
Serial.println(msg);
//------------------------------------------------------
sprintf(char_array_number,"1234");
Serial.println(char_array_number);
//------------------------------------------------------
int_number = atoi(char_array_number);
Serial.println(int_number);
//------------------------------------------------------
int_number_2 = 5;
itoa(int_number_2,char_array_number_temp1,10);
Serial.print("char_array_number_temp1: ");
Serial.println(char_array_number_temp1);
strcpy(char_array_number_temp2,"0");
strcat(char_array_number_temp2, char_array_number_temp1);
Serial.print("char_array_number_temp2: ");
Serial.println(char_array_number_temp2);
//------------------------------------------------------
}
void loop() {
//------------------------------------------------------
// this approach works:
if(int_number == 1234)
{
Serial.println("yes");
}
else{
Serial.println("no");
}
//------------------------------------------------------
// this approach works:
if(txt == "bye")
{
Serial.println("yes");
}
else{
Serial.println("no");
}
//------------------------------------------------------
// DO NOT USE, this approach doesn´t works:
if(char_array_value == "hello")
{
Serial.println("yes");
}
else{
Serial.println("no");
}
//------------------------------------------------------
// this approach works:
if(strcmp(char_array_value,"hello") == 0) //0 indicates str1 is equal to str2.
{//equal:
Serial.println("yes");
}
else
{//different:
Serial.println("no");
}
//------------------------------------------------------
//------------------------------------------------------
Serial.println("Programm Stop");
while(1);
}
void firebaseSetCharArray(char* path, char* var, char* value)
{
// String Path = path + MacAddressWiFi + "/" + var;
// String Value = value;
strcpy(char_path,path);
strcat(char_path,char_MacAddressWiFi);
strcat(char_path,"/");
strcat(char_path,var);
}