Write a small C program to determine whether a machine's
type is little-endian or big-endian.
Answers were Sorted based on User's Feedback
Answer / vasundhara
int main()
{
int x=1;
if(*(char*)&x)
printf("little endian");
else
printf("big endian");
return 0;
}
Is This Answer Correct ? | 7 Yes | 1 No |
Answer / anuraag
Vasudhara's solution is correct!
Still here is an alternative solution to check endianess
without using pointers...
int main()
{
int x=0x58;
char ch;
ch=x;
if(ch=0x58)
printf("Little Endian");
else
printf("Big Endian");
return 0;
}
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / mohana
The below code snipeet tells whether the system is little
or big endian.
int main()
{
int x=1;
if(x)
printf("big endian");
else
printf("little endian");
return 0;
}
Is This Answer Correct ? | 7 Yes | 24 No |
What is huge pointer in c?
What is meant by high-order and low-order bytes?
Write a program to identify if a given binary tree is balanced or not.
What is the c value paradox and how is it explained?
What is memory leak in c?
if the address of a[1,1] and a[2,1] are 1000 and 1010 respectively and each occupies 2 bytes then the array has been stored in what order?
4 Answers Amazon, Apple, Bata, Google, NASA,
Which programming language is best for getting job 2020?
Write a function to find the area of a triangle whose length of three sides is given
Write the test cases for checking a variable having value in range -10.0 to +10.0?
Write a program to find the biggest number of three numbers in c?
What is pass by reference in functions?
write a program to find out number of on bits in a number?