I have a class containing few char*
variables:
char* msgTopic = "myHome/MSGS";
char* groupTopic = "myHome/All";
char* errorTopic = "myHome/Err";
but, I wish to have it defined outside the class and not hardcoded (update only prefixTopic
outside the class,
char* prefixTopic = "myHome";
char* msgTopic = ""; // also tried--> char* msgTopic = "AAAAAAAAAAA";
char* groupTopic = "";
char* errorTopic = "";
and then, down the code to have it defined as:
sprintf(msgTopic ,"%s/Messages",prefixTopic);
sprintf(groupTopic,"%s/All",prefixTopic);
sprintf(errorTopic,"%s/Errors",prefixTopic);
BUT
both ways ( when defining variables as ""
, or just filled it up with chars to allocate space) caused topics to be defined with errors ( mostly - one variable contained both topics ).
Appreciated any help ( I don't think context of class is relevant )