c++ - same printf gives different results -
This is my first post and hopefully it is not a repost, I have to compile the following C ++ program on Mac For G ++ used.
#include & lt; Iostream & gt; int main () {double b = 1; Printf ("% x \ n", b); Printf ("% x \ n", b); Printf ("% x \ n", b); Printf ("% x \ n", b); Return 0; } Why does the program give me different results of the same code? Here's the output.
5ca5ebf8 100 200 300 This behavior is not shown in the VS on Windows. Thank you.
This is a warning that you should meet with a decent compiler: Warning: the format specified Type 'unsigned' int 'but the argument is type' double ' So you get undefined behavior, anything can happen :)
Comments
Post a Comment