Home > Back-end >  The C language
The C language

Time:03-19

Beginners small white, why become zero sum value,,,,

CodePudding user response:

Sum=% d ;
Instead of
Sum=% . ;

CodePudding user response:

reference 1/f, zhao teacher reply:
Sum=% d ;
Instead of
Sum=% . ;

Oww,,,, thank you

CodePudding user response:

Because of type int and double type data in memory is not the same, % d output said to let the computer by using the format to get data of type int, and half of the int or double memory, so the picked are 0. (low 4 bytes, 32 bit system)

CodePudding user response:

reference 3 building self-confidence boy reply:
because int type and type double data in memory is not the same, % d output said to let the computer by using the format to get data of type int, and half of the int or double memory, so the picked are 0. (low 4 bytes, 32 bit system)

I think they said wrong format character just go wrong, such detailed description undefined behavior is not so good. (I am not too sharp) thoughtfully for a long time want to tone
  • Related