Output difference in gcc and turbo C

前端 未结 7 527
野趣味
野趣味 2020-12-15 22:46

Why is there a difference in the output produced when the code is compiled using the two compilers gcc and turbo c.

#include 

        
7条回答
  •  孤城傲影
    2020-12-15 23:44

    Historical footnote: Since addresses were smaller than floating-point numeric constants, FORTRAN used to handle floating-point constants much like C handles strings. Since memory was precious, identical constants would be allocated the same space. Also, parameter passing was always done by reference. This meant that if one passed a numeric constant to a procedure that modified its argument, other occurrences of that "constant" would change value.

    Hence the old saying: "Variables won't; constants aren't."

    Incidentally, has anyone noticed the bug in the Turbo C 2.0 printf which would fail when using a format like "%1.1f" to print numbers like 99.99 (outputs 00.0)? Fixed in 2.01, it reminds me of the Windows 3.1 calculator bug.

提交回复
热议问题