I am currently wondering if there is a way to replace the format specifier %u by nothing using sprintf
My question is about the use of a ternary operator in sprintf which gonna replace %u by a value or by nothing.
Here is an example of what I am trying to do :
int main (void)
{
char mytab[10]={'\0'};
uint_32 i=0;
scanf("%u",&i);
sprintf(mytab, "\"%u"\",i>0?i:/*Here is the syntax I want to find if it exists*/);
printf("%s\r\n",mytab);
return 0;
}
The result of the code I am trying to get is for example "1" if the input is 1 (or "2" if the input is 2...) and "" if the input is 0.
Do you have any ideas or explantion about it ? Thanks by advance.