Little and Big Endian



In my early college days, I saw some notes on typecasting. writer was trying to explain
typecasting with an example code given below:

#include<stdio.h> 
int main()
{
    int x=0xA2213014;
    printf("Typecasted Output: %d\n",*(char*)&x);
    return 0;

}

Output:
Typecasted Output: 162

But when I compiled and executed same example on my desktop, the output was
Typecasted Output: 20


One thought came in my mind "people write any thing". Later when I came to know about endian, then I understood that he must have run the program on any big endian machine.
It is important to understand endianness to write a portable program. I am trying to explain it in my presentation.






Your suggestions are alaways welcome. Please provide your feedback to improve it.

2 comments:

Ikem said...

What tool do you used to embed the presentation?

Ganga R Jaiswal said...

Uploaded my presentation on slideshare.net and they provide a link to embed the presentation on your web page.

Simple theme. Powered by Blogger.