Answers:
Here is a small code segment to determine the endianess of a system at run time.
short int number = 0x1; char *byte = (char*)&number; if ( byte[0] ) printf("Little endian"); else printf("Big endian");
Submitted by Pooja Agrawal (poojas@gmail.com)
unsigned int a = 0x01; a = a>>1; if(a){ printf("little endian"); }else{ printf("big endian"); }
Posted by: Rakesh
Contact Rakesh
unsigned char device_set_flag=0x01;
if((device_set_flag >> 1) & 0x01) // little endian else // big endian
Posted by: Ratnesh
Contact Ratnesh
int number = 0x01; if ( (number | 0xff) == 0x01 ) printf("Little endian"); else printf("Big endian");
Posted by: Durgaprasad
Contact Durgaprasad
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
There should not be any Spelling Mistakes.
There should not be any Gramatical Errors.
Answers must not contain any bad words.
Answers should not be the repeat of same answer, already approved.
Answer should be complete in itself.
   
|