how to find your architecture is LittleEndian or BigEndian?

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the maximum length of an identifier?

651


What is the use of f in c?

543


What is a nested loop?

635


What is meant by int main ()?

704


What is a structure member in c?

532






Explain the difference between malloc() and calloc() in c?

563


Here is a good puzzle: how do you write a program which produces its own source code as output?

585


How can I invoke another program (a standalone executable, or an operating system command) from within a c program?

637


What are high level languages like C and FORTRAN also known as?

665


How do you generate random numbers in C?

637


Which one would you prefer - a macro or a function?

588


What is meant by preprocessor in c?

520


What is the difference between volatile and const volatile?

554


What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?

596


hi to every one .. how to view table pool after creating the pooled table? plz help me.. if any knows abt this ..

1448