The weather will be fine on Monday, February 1, 2021 [Do not lament the past, do not waste the present, do not fear the future]
printf(str): Since it printf
supports variable parameters, the number of subsequent variables needs to be determined by the format string in str. When the str
string contains an %s,%d,%c
equal format string, printf
it will go to the stack to find the variable corresponding to the format string, but in fact, no printf
more parameters are pushed at all , so printing failure or program crash will occur. As shown in the figure below:
Therefore, when writing code, you must not use it printf(str)
, and use it honestly printf(str,%s)
.
references
https://blog.csdn.net/readonlyfile/article/details/25222587?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-5.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-5.control