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

What was noalias and what ever happened to it?

0 Answers  


write a “Hello World” program in “c” without using a semicolon?

9 Answers   CTS, TCS, Wipro,


Write a program to display the no of bit difference between any 2 given numbers eg: Num1 will 12->1100 Num2 will 7->0111 the difference in bits are 2.

4 Answers  


What is the difference between break and continue?

0 Answers  


What is the function of ceil(X) defined in math.h do? A)It returns the value rounded down to the next lower integer B)it returns the value rounded up to the next higher integer C)the Next Higher Value D)the next lower value

3 Answers   Accenture, Wipro,






What is the scope of local variable in c?

0 Answers  


difference between string and array?

6 Answers  


What is the difference function call by value & function call by reference?

6 Answers  


a C prog to swap 2 no.s without using variables just an array?

5 Answers   TCS,


What is data structure in c programming?

0 Answers  


what do you mean by inline function in C?

0 Answers   IBS, TCS,


what is event driven software and what is procedural driven software?

0 Answers  


Categories