0

1Long int is c++ is of 8 byte but my compiler shows me the result of only 4 bytes and then i put same code in online compiler i got 8 byte

image of mingw64 compiler

image of onlie compiler

Jason
  • 36,170
  • 5
  • 26
  • 60
  • Both are valid sizes of a `long`. – tkausl Aug 07 '22 at 02:22
  • but why this happens online compiler is showing 8 and mingw64 4 bytes ?? – Krishna Kumar Aug 07 '22 at 02:31
  • 1
    `long` can be any size 32 bit or greater. Use `int64_t` if you want exactly 64 bits – M.M Aug 07 '22 at 02:31
  • 1
    `but why this happens online compiler is showing 8 and mingw64 4 bytes ??` Because those are different compilers and do things differently. Again, __both__ 32 bit __and__ 64 bit are valid sizes for a `long int` according to the C++ Standard. – tkausl Aug 07 '22 at 02:32
  • Does this answer your question? [What does the C++ standard state the size of int, long type to be?](https://stackoverflow.com/questions/589575/what-does-the-c-standard-state-the-size-of-int-long-type-to-be) – Jason Aug 09 '22 at 15:07

0 Answers0