Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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 ajoutée par Somnath Roy
Date de publication: 2014/03/18
Syed Aamir Mehdi Hasni
par 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
par 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

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?