hello everyone, i m writing a c program to find the host byte error but it is not executing....cud any1 plz plz plz help me out in sorting this out.
thanks a lot in advance
Code:
#include<stdio.h>
int main()
{
int a,i;
char b[sizeof(a)];
printf("enter b");
for(i=0;i<sizeof(a);i++)
{
scanf("%c",&b[i]);
}
if(sizeof(a)==4)
{
if(b[1]==1 && b[2]==2 && b[3]==3 && b[4]==4)
{
printf("big endian");
}
else if(b[1]==4 && b[2]==3 && b[3]==2 && b[1]==1)
{
printf("little endian");
}
}
else
{
printf("invalid");
}
}