Need a refresher here...been ages since I wrote a function that returns a charpointer.
Is the following safe?
#define CHECK_MODE 100
#define PROCESS_MODE 200
// return a string that contains the mode currently in use
char *ShowMode(int mode)
strcpy(mode_buff, "CHECK MODE");
strcpy(mode_buff, "PROCESS MODE");
mode_buff = 0;
<set the mode here>
printf("The mode is %s\n", ShowMode(mode));
My concern is that I have some vague memory that for functions that return a charpointer, the variable you return must be a function argument (or perhaps a static char declared locally within the function). My way, you have a local char, but it's not static.