Long和Int

扫码查看
(或者`int`s,就此而言),即使在6位机器上也是如此。 - BR,Vladimir 我在刮!我正在刮胡子! 是的。 C语言保证某些最小值和 类型之间的某些关系: bits(char)> = 8 bits (短)> = 16&& bits(短)> = bits(char) bits(int)> = 16&& bits(int)> = bits(短) 位(长)> = 32&&位(长)> =位(int) 位(长很长)> = 64&& bit(long long)> = bits(long) (C99中引入了`long long''类型.C99还允许实现实现定义他们自己选择的其他类型, 遵守各种规则;我没有试图列举 这些异国情调整数,因为会有不同的在不同的实现上设置 。) - Er ********* @ sun.com Hi,I am a beginer programmer, i would like to know the exact differencebetween long and int. Why do we have two names for the same size ofvariable.Does the size of long and int change on various architectures..thanks,carl 解决方案It sometimes does, but that is not required either. It depends more onthe actual C implementation than on the underlying architecture.There''s nothing stopping an implementation from having 64-bit `long`s(or `int`s, for that matter), even on a 6-bit machine.--BR, VladimirI''m shaving!! I''M SHAVING!!You mean "range", not "size". The range of int is a subrange ofthe range of long. There are no such guarantees about the sizesof int and long.--int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\);}return 0;}Yes. The C language guarantees certain minima andcertain relationships between the types:bits(char) >= 8bits(short) >= 16 && bits(short) >= bits(char)bits(int) >= 16 && bits(int) >= bits(short)bits(long) >= 32 && bits(long) >= bits(int)bits(long long) >= 64 && bits(long long) >= bits(long)(The `long long'' type was introduced in C99. C99 also allowsimplementations to define other types of their own choosing,subject to various rules; I haven''t attempted to enumeratethese "exotic" integers because there''ll be different setson different implementations.)-- Er*********@sun.com 这篇关于Long和Int的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-01 09:07
查看更多