-
Notifications
You must be signed in to change notification settings - Fork 0
/
42_endian.c
38 lines (35 loc) · 923 Bytes
/
42_endian.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/****************************************************************
DOCUMENTATION:
NAME :V.KARTHIEKEYAN
DATE :23.06.2021
DESCRIPTION :WAP to check your processor endianess
OUTPUT :./a.out
ENTER ANY NUMBER: 25
LITTLE ENDIAN SYSTEM
DO YOU WANT TO CONTINUE:n
****************************************************************/
#include<stdio.h>
int endian(unsigned int num,char *cptr);
int main()
{
char choice;
unsigned int num=0;
char *cptr;
cptr=(char *)#
printf("ENTER ANY NUMBER: ");
scanf("%d",&num);
endian(num,cptr);
printf("\nDO YOU WANT TO CONTINUE:");
scanf(" %c",&choice);
if( choice == 'Y' || choice == 'y' )
main();
return 0;
}
int endian(unsigned int num, char *cptr)
{
int check = 0xff & num; //take the first byte
if( check == *cptr ) //*cptr points to first byte
printf("LITTLE ENDIAN SYSTEM");
else //*cptr points to last byte
printf("BIG ENDIAN SYSTEM");
}