how to find your architecture is LittleEndian or BigEndian?



how to find your architecture is LittleEndian or BigEndian?..

Answer / kirankumaryakkala

ans. by using unions we can find it see.
union
{
char ch[2];
int i;
}u;
u.i=512;
printf("%d %d",u.ch[0],u.ch[1]);
printf("%d",u.i);

basically u will see this type of implementation while u r
going through some C books.

depending on the storage seen at ch[0],ch[1] u can find.

u can find the output as ch[0]=0,ch[1]=2 \\little endian
(or) ch[0]=2,ch[2]=0\\bigendian
like this u can find the endian....

Is This Answer Correct ?    3 Yes 1 No

Post New Answer

More C Interview Questions

Explain what is the best way to comment out a section of code that contains comments?

0 Answers  


how to exchnage bits in a byte b7<-->b0 b6<-->b1 b5<-->b2 b4<-->b3 please mail me the code if any one know to rajeshmb4u@gmail.com

3 Answers   Honeywell, Huawei,


with out using main how to execute the program?

2 Answers  


Q-1: Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college.

8 Answers  


difference between native and cross compilers

0 Answers  






What ios diff. Between %e & %f?

3 Answers   Honeywell,


Write a function in c to find the area of a triangle whose length of three sides is given.

2 Answers  


Write a program to identify if a given binary tree is balanced or not.

0 Answers   JPMorgan Chase,


errors in computer programmes are called

1 Answers   NET,


Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?

0 Answers  


difference between string and array?

6 Answers  


how to execute a program using if else condition and the output should enter number and the number is odd only...

0 Answers  


Categories