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 best style for code layout in c?

634


What is the size of structure in c?

705


What is a floating point in c?

607


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

675


In which language linux is written?

607






What are the differences between Structures and Arrays?

614


1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.

2339


Can we declare variables anywhere in c?

582


How do you use a 'Local Block'?

728


What is this pointer in c plus plus?

600


#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }

633


Is printf a keyword?

762


How do you define structure?

571


How can I rethow can I return a sequence of random numbers which dont repeat at all?

708


What are the different data types in C?

731