printf too smart casting from char to int?
问题 Why does the following call: printf("%d %d", 'a', 'b'); result in the "correct" 97 98 values? %d indicates the function has to read 4 bytes of data, and printf shouldn't be able to tell the type of the received arguments (besides the format string), so why isn't the printed number |a||b||junk||junk| ? Thanks in advance. 回答1: In this case, the parameters received by printf will be of type int . First of all, anything you pass to printf (except the first parameter) undergoes "default promotions