I think you understand the printf syntax well, but I think you are missing something in the C syntax.
It is a form of the "compact IF like" statement, formatted as follows: (condition? True: false)
For example, you can:
int a=5; int b=(a==5 ? 128 : 256); int c=(a!=5 ? 8 : 9);
In this case, b = 128 and c = 9.
Another example:
int flag=1; printf("The value is: %s", (flag!=0 ? "true" : "false) );
In this case, you can see: true
In your example:
printf(i>j?"%50s":"%s",str);
if I am the top j, you use the format "% 50s", and if I am lower, you use the format "% s"
It could be a view:
if (i>j) printf("%50s",str); else printf("%s",str);
You can see the advantage of compact test.
source share