Header Ads

31 - WAP to check if Processor is Little Endian or Big Endian in C

This program check's if Processor is Little Endian or Big Endian in C

Program Code :
//it will check whether the processor is little endian or big endian
#include <stdio.h>

 //main function
int main()
{
 //variable declaration
 int num = 1;
 char *ptr = (char *)&num;

 //checking the condition if it's one or not
 if (*ptr == 1)
 {
  printf("It's Little Endian!\n");
 }
 else
 {
  printf("It's Big Endian!\n");
 }
 return 0;
}

Program Output: 

No comments