So this code is invalid according to you (not complete):
Code:
int main()
{
char *res = "Unknown";
char buffer[100];
int somestuff = somefunc();
switch(somestuff)
{
case 1:
case 2:
sprintf(buffer, "Result = %d", somestuff);
res = buffer;
if ((somestuff = someotherfunc()))
strcat(res, " extra stuff");
break;
default:
// ...
}
printf("Res=%s\n", res);
return 0;
}
Yes, I'm sure it CAN be rewritten to use const wherever needed, but I can certainly see how you would want to do similar work in a function SOMETIMES.
--
Mats