ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Can any one tell me how to store a data in little endian machine using big endian format ? i am using little endian compiller ?

user-image
تم إضافة السؤال من قبل Somnath Roy
تاريخ النشر: 2014/03/18
Syed Aamir Mehdi Hasni
من قبل Syed Aamir Mehdi Hasni , Java Developer , Hewlett Packard Enterprise

// Use  this  code For  storing data  in  big  endian  format  in little endian machine  , u can  c0mpile &  check !!!!!!!!

#include<stdio.h>void yup(char *start,int n){int i;for(i=0;i<n;i++)printf("%x",start[i]);printf("\\n");}void main(){int i=0x;printf(".......................little endian............................\\n");yup((char *)&i,sizeof(i));int b=((i>>24)&0x00ff)|((i>>8)&0xff00)|((i<<8)&0x00ff0000)|((i<<24)&0xff000000);//printf("%x\\n",b);printf("...............converted into bidendian..........................\\n");yup((char*)&b,sizeof(i));}

dinesh nagar
من قبل dinesh nagar , Senior Engineer Electrical and Electronics maintenance , Gajra gears pvt ltd dewas madhya pradesh

WITH THE HELP OF RIGHT SHIFT DATA WE CAN CONVERT DATA FIRST INTO BIG ENDIAN TO LITTLE ENDIAN .

Little and big endian are two ways of storing multibyte data-types ( int, float, etc). In little endian machines, last byte of binary representation of the multibyte data-type is stored first. On the other hand, in big endian machines, first byte of binary representation of the multibyte data-type is stored first.

المزيد من الأسئلة المماثلة