Saturday, July 2, 2011

C++ Program to find the Endian nature of a processor

Before going to the progaram,
what is endian nature?

There are two kinds of endian nature... One is li'l edian and the other is big endian...

This pic could illustrate you:

Now, this is my own way of finding the endian nature:



#include
#include
#include
void main()
{
   clrscr();
   int a[10],*b[10];
   for(int i=0;i<10;i++)
   {
      a[i]=i+1;
      b[i]=&a[i];
      cout<<"\na["<<<"]:"<
      cout<<"\t"<<"is stored in:\t"<
   }
   getch();
}



Simply saying, if the character array stores ur string in the same order as you give, then the processor is big endian. Else if it stores in the reverse order, its little endian. :-)


Most of you people use Intel Mother borads.. Hence, you will find the result as little endian :-)

No comments:

Post a Comment