Monday, April 5, 2010

Understanding Pointers with inner wears :)

It was the summer of 2007 when I was waiting for the Joining dates of Infosys Technologies (I waited till winterJ). During those days, I used to visit some C language communities on Orkut. One day I saw a very interesting discussion about the pointers in C.

One guy asked a question in the C community:

Why can't an integer pointer point to a floating number????

Immediately after this, there was another question commeting to the above question:

Why can't boys wear bra and panties????

Some supported this comment and some gave nice replies to the actual question. Here is what I replied to the post….


“Any pointer type always points to a single byte.... and that byte is always the starting byte of the variable...
if a variable is a pointer, it will store the address of the first byte of the variable only.

So, you can store the address of the any type of the variable to the any type of the pointer.......
now the question arises... THEN WY DIFFERENT TYPES Of POINTERS......

By making a type of pointer ... it tells the compiler that how many bytes a processor will process wen it will encounter the pointer.
In dos environment...
If integer pointer..... will process two bytes simultaneously.
If float pointer..... Will process 4 bytes.

And it also tells to the compiler that on increment..... Which byte will be the next address.
i.e. if float pointer is ptrf, then ptrf++ will jump on the 5th next byte.

so...... store anyone, anywhere... But don’t put your expectations.......
in a nutshell......
"boys can wear panties and bra..... But don’t expect them to behave like a girl"


Though the discussion was really good but what I remember even today is the last line of my replyJ. And so the subject line of the blog.

1 comment: