आप इसके लिए संघों का उपयोग कर सकते हैं। एंडियननेस मायने रखता है, इसे बदलने के लिए आप x86 बीएसडब्ल्यूएपी निर्देश (या किसी अन्य प्लेटफ़ॉर्म के लिए अनुरूप) का उपयोग कर सकते हैं, जो अधिकांश सी कंपाइलर्स द्वारा अंतर्निहित के रूप में प्रदान किया जाता है।
#include <stdio.h>
typedef union{
unsigned char bytes[8];
unsigned short int words[4];
unsigned int dwords[2];
unsigned long long int qword;
} test;
int main(){
printf("%d %d %d %d %d\n", sizeof(char), sizeof(short), sizeof(int), sizeof(long), sizeof(long long));
test t;
t.qword=0x0001020304050607u;
printf("%02hhX|%02hhX|%02hhX|%02hhX|%02hhX|%02hhX|%02hhX|%02hhX\n",t.bytes[0],t.bytes[1] ,t.bytes[2],t.bytes[3],t.bytes[4],t.bytes[5],t.bytes[6],t.bytes[7]);
printf("%04hX|%04hX|%04hX|%04hX\n" ,t.words[0] ,t.words[1] ,t.words[2] ,t.words[3]);
printf("%08lX|%08lX\n" ,t.dwords[0] ,t.dwords[1]);
printf("%016qX\n" ,t.qword);
return 0;
}
आप एक ही मशीन पर यह कर रहे हैं तो कोई यह कोई बात नहीं, आप एक मशीन है कि * हो सकता है * एक अलग endian सत्ता के लिए नेटवर्क पर भेज रहे हैं और फिर परिवर्तित करने के लिए कोशिश कर रहा है, तो हाँ यह कोई फर्क नहीं पड़ता। –
संक्षिप्त उत्तर यह है कि अंतहीनता 1 बाइट से बड़े पूर्णांक के लिए मायने रखती है। किसी और चीज के लिए नहीं ('सामान्य' कंप्यूटर पर) – xaxxon