Category Archives: Uncategorized

Interesting C code

This is interesting only for C programmers, and probably not useful even to them.
But you’re still reading, so I guess you’re really jobless. So here it is:
Anyone familiar with pointers in C knows the output of this code:

int arr[3] = {5,6,7};

(OUTPUT : 7)

But did you know that even this code works :

int arr[3] = {5,6,7};

(OUTPUT : 7)

Amazing, huh?

(Nah, not really… I just write these articles to show people that they’re geeks! But do read on…)

Well, here’s how it works:

You probably know that arr[2] is equivalent to *(arr + 2)

Actually, arr[2] converts internally to *(arr + 2) before evaluation

So, if

arr[2] => *(arr + 2)

Isn’t it quite reasonable to  expect that

2[arr] => *(2 + arr)

Well, reasonable or not, thats how it works! And I’m sure you know *(x + 2) is equivalent to *(2 + x), so there!

Makes perfect sense doesn’t it!

arr[2] is equivalent to 2[arr]     !!!!!!!!!!!!!!!!

Why I hate ubuntu (right now)

The thing about problems in Ubuntu is that they just never go away. Here is my painful experience:
My second round with Ubuntu has gotten off to a rocky start (just like my first attempt about a year ago…. ) It all started with a simple prompt in Firefox to install flash-player. I had some important work I needed to do, but I thought, “I’ll need to do this sometime or the other, might as well do it now. Its only a click anyway.”
Well…. I should have known better.
It started off decently enough and I continued with my other work …. but I kept getting nagged by the fact that the update hadn’t completed…. it was probably my spider sense giving me a warning.
Anyway, I saw that it had gotten stuck, and decided to pull the plug on the sucker. A click on the red X in Windows XP would have done the trick, but not here…
I tried to close the update window, which caused it (also) to get stuck. Then I tried to close firefox, but guess what ….. it was (also) stuck (too).
Now my mouse click stopped working (though the cursor moved and hover effects were still working…. so at least I had graphics through the ordeal)
Somehow I noticed that my mousepad (I’m using a laptop) still had a functioning click, so I at least had some consolation.
Now I found myself cut-off from the internet, the one place where I might get help.
But with my mousepad I was able to restart…..
Now I was back and things seemed fine, so I decided to install pidgin so that I could at least have a lifeline to my brother when (not if) things went wrong.
But guess what?
Now I couldn’t install anything because the flash player install had locked up my synaptic manager, so that nothing could move forward.
Now I speak to you after 2 hours of going through at 30 different links and solutions, only to find that nothing works!!
Anyway, I guess its things like this that allow programmers to have jobs. So cheers!