Char Str[] problem

Hi,

When compiling my sketch, it point out to be an error about my string. Couldnt figure out what it is. Any solution?

The error I have is expected primary expression before token. It high light the first line that I use Str1[ ] .

char Str1[ ] = "...";
.....
.....
.....

void alarm(){
   
  if(fr_temp >= 42){
     temp_alarm = 1;
     Str1[ ] = "ON : Temperature is over 42 Celsius";
  }
  if(fr_temp < 42){
    temp_alarm = 0;
    Str1[ ] = "OFF : No temperature alarm detected";
  }
}

I have also try with this. Both expression are 36 char

char Str1[36];
...
...
void alarm(){
   
  if(fr_temp >= 42){
     temp_alarm = 1;
     Str1[ ] = "ON : Temperature is over 42 Celsius";
  }
  if(fr_temp < 42){
    temp_alarm = 0;
    Str1[ ] = "OFF : No temperature alarm detected";
  }
}

what is all this

.....
.....
.....

Str1 is declared as an array, not a pointer.

You need to either declare it as an array big enough to hold the biggest message, and copy the message in to the array when you want to update it, or (more sensible IMO) declare it as a pointer.

If it's a compiler error, you ALWAYS should post ALL of your code.

     Str1[ ] = "ON : Temperature is over 42 Celsius";

That line is wrong. You can't assign to an array like that. This compiles, and just does pointer assignment:

int fr_temp, temp_alarm;

char* Str1 = "...";

void alarm()
  {
   
  if(fr_temp >= 42)
  {
     temp_alarm = 1;
     Str1 = "ON : Temperature is over 42 Celsius";
  }
  if(fr_temp < 42)
  {
    temp_alarm = 0;
    Str1 = "OFF : No temperature alarm detected";
  }
}

void setup () {}
void loop () {}

Arrch:
If it's a compiler error, you ALWAYS should post ALL of your code.

It is impossible, the forum doesnt allow to post more than something like 1000 char....
I got about 5 pages of code....

BUt thanks for the help, I managed something and its now working

For future reference, when you post, under additional options, you can attach a file of much larger size than the forum restriction on text.