Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

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
Question added by Somnath Roy
Date Posted: 2014/03/18
Syed Aamir Mehdi Hasni
by 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
by dinesh nagar , Service head , Vaayu India home appliances pvt. ltd

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.

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.