weirder。 干杯 弗拉基米尔 没有什么可以详细说明的 - 这取决于你使用的硬件。这些通常都是低端和高端的口味(首先是低阶和高阶位),但是没有什么可以禁止的东西。 弗拉基米尔 对不起,发送太快了...... 确定的方法你的机器如何存储数据: 将一个int变量初始化为具有不同高位和 低位的东西。使用char *指向它并在那里读出 值。如果在你的系统上char比int更窄,那么你很幸运,并且能够在读取的值上告诉基于字节序的 。如果sizeof int == sizeof char,你可以尝试 来使用long,而不是int,或者任何比char更宽的的整数类型。 无论如何,练习应该很有趣...... ;-) 干杯 弗拉基米尔 lets consider that I have defined an integer like this.int a=5;now taking the fact that an integer is allocated 2 bytes in memory andthe memory address increases in the left to right direction, which wayis the 16bit representationof 5 stored..i.e 15 is 0000000000001111 representation in binary right? if thememory address increases in left to right direction with each memoryaddress being capable of holding 8bits (i.e 1 byte)..can u tellme thestructure in which it is stored..is it like this???00 00 00 00 00 00 11 11^lesser address ^greater address.or is it in different format?Please elaborate.Thank you very much for ur patience.Bye 解决方案There''s nothing really to elaborate -- it depends on thehardware you''re using. These generally come in low- andhigh-endian flavours (lower order vs higher order bits first,respectivelly), but there''s nothing proscribing somethingweirder.CheersVladimirA core dump in binary of the integer you describe might be:00000000 00001111ASSUMING: CHAR_BIT = 8, 16-bit integer, and bit-endian.Gordon L. Burditt There''s nothing really to elaborate -- it depends on the hardware you''re using. These generally come in low- and high-endian flavours (lower order vs higher order bits first, respectivelly), but there''s nothing proscribing something weirder. Cheers VladimirSorry, hit send too quickly...The way to determine how your machine stores data:Initialise an int variable to something with different high- andlow-order bits. Point to it using a char* and read out thevalue there. If on your system char is narrower than an int,you''re in luck, and will be able to tell the endianness basedon the value read. if sizeof int == sizeof char, you could tryto use long, instead of int, or any integer type that''s widerthan char.In any case the exercise should be fun... ;-)CheersVladimir 这篇关于如何确定数据存储在内存中的方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!