Why printf is not able to handle flags, field width and precisions properly?
问题 I'm trying to discover all capabilities of printf and I have tried this : printf("Test:%+*0d", 10, 20); that prints Test:%+100d I have use first the flag + , then the width * and the re-use the flag 0 . Why it's make this output ? I purposely used printf() in a bad way but I wonder why it shows me the number 100? 回答1: This is because, you're supplying syntactical nonsense to the compiler, so it is free to do whatever it wants. Related reading, undefined behavior. Compile your code with