Regarding Strings and assignments I have this code which works :

String ErrorMsg;
.......
if(!UploadPacketError)
{
    ErrorMsg="OK";
}
else
{
   ErrorMsg="NOK";
}


String creates a dynamically allocated array which I want to avoid. I would prefer something like :

unsigned char ErrorMsg[5];
......
if(!UploadPacketError)
    {
        strcpy(ErroMsg,"OK",3); // +1 for the Null Termination ?
    }
    else
    {
       strcpy(ErroMsg,"NOK",4); // +1 for the Null Termination ?
    } 


i.e. is there a way to dynamically assign a value to a fixed size character array ?

Cheers
Thomas
Almost.

First it's char not unsigned char:

char ErrorMsg[5];`


Second you don't specify a size with strcpy:

strcpy(ErrorMsg, "OK");


There is a variant of strcpy called strncpy which copies at most n characters:

strncpy(ErrorMsg, "OK", 5);


That is used to prevent buffer overruns. But when working with string literals like that it's pretty pointless.