I am trying to use format specifier within switch however compiler returns error: expression result unused
const char* text;
const char* input;
int i=2;
input = "orange";
switch(i){
case 1:
text = "%s is color", input;
break;
case 2:
text = "%s is fruit", input;
break;
default:
break;
}
text.printf()family of functions. In general in C if you want something "complicated" (such as converting various values to string representations) to happen, you need to call a function that implements that.text = "%s is color", input;and similar statements: This is nonsense. Your compiler is telling you that. Strongly suggest usingsprintf()to format the contents of a char array, then you could assign the address of that array toinputortext