Long Vs. Int C/C++ - What's The Point?

前端 未结 5 399
情深已故
情深已故 2020-12-12 22:00

As I\'ve learned recently, a long in C/C++ is the same length as an int. To put it simply, why? It seems almost pointless to even include the dat

5条回答
  •  忘掉有多难
    2020-12-12 22:49

    When writing in C or C++, every datatype is architecture and compiler specific. On one system int is 32, but you can find ones where it is 16 or 64; it's not defined, so it's up to compiler.

    As for long and int, it comes from times, where standard integer was 16bit, where long was 32 bit integer - and it indeed was longer than int.

提交回复
热议问题