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 do you write a program which produces its own source code as its output?

2 Answers  


What are the different types of linkage exist in c?

0 Answers  


What is class and object in c?

0 Answers  


Can i use Two or More Main Funtion in any C program.?

4 Answers  


What is #include conio h?

0 Answers  






Why can’t constant values be used to define an array’s initial size?

0 Answers  


Can math operations be performed on a void pointer?

0 Answers  


a number is perfect if it is equal to the sum of its proper divisor.. 6 is perfect number coz its proper divisors are 1,2 and three.. and 1+2+3=6... a number is deficient if the sum of its proper divisor is less than the number.. sample: 8 is deficient, coz its proper divisors are 1,2 and 4, and 1+2+4=7. abundant number, if the sum of its proper divisor is greater than the number.. sample..12 is abundant coz 1+2+3+4+6=16 which is geater than 12. now write a program that prompts the user for a number, then determines whether the number is perfect,deficient and abundant..

1 Answers  


Is c compiled or interpreted?

0 Answers  


Are local variables initialized to zero by default in c?

0 Answers  


palindrome for strings and numbers----Can anybody do the prog?

6 Answers   CTS, TCS, Vipro Lifescience Pvt,


how can i get the string which is having two spaces at the end.suppose the string is "Hello World ".Now at the end i have two spaces.i need to print with that spaces .

1 Answers  


Categories