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