Skip to main content

given number is little endian or big endian?

 Given number is little endian or big endian?



#include <stdio.h>
int main()
{
unsigned int n = 1;
char *p;
p = (char*)&n;
if (*p == 1)
printf(ā€œLittle Endian\nā€);
else if (*(p + sizeof(int) ā€“ 1) == 1)
printf(ā€œBig Endian\nā€);
else
printf(ā€œSurprise output!!!!\nā€);
return 0;
}

Comments

Popular posts from this blog

CAN INTERVIEW QUESTIONS

Qualifiers and Modifier in C

RTOS Real time operating system interview questions

CAN INTERVIEW QUESTIONS 2

What is UDS protocol

Memory mapping in c

TOP IOT PLATFORMS