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

How does normalization of huge pointer works?

0 Answers  


What is the difference between near, far and huge pointers?

0 Answers  


What is main () in c?

0 Answers  


#include <stdio.h> int main() { if ("X" <"x") printf("X smaller than x "); } my question is whats the mistake in this program? find it and please tell me..

3 Answers  


Finding first/last occurrence of a character in a string without using strchr( ) /strrchr( ) function.

2 Answers  






write a program to display & create a rational number

1 Answers   HCL, TCS,


Explain how can you restore a redirected standard stream?

0 Answers  


1.)how to find d most repeated word in a string? string ="how do you do"?? output should be do

1 Answers   AAS, Nagarro, Vuram,


write a program to generate address labels using structures?

0 Answers   SJC,


How do you declare a variable that will hold string values?

0 Answers  


Explain what is the difference between null and nul?

0 Answers  


print a "hello" word without using printf n puts in c language

6 Answers  


Categories