Archive for January, 2007

iPhone

January 9, 2007

Finally, a reason to replace my mobile phone… and iPod! For all who have been appart from all the fuzz, i’m talking about the now-official iPhone. This new phone does look like a totally different phone, starting with support for Wifi, bluetooth, GSM and EDGE, and finishing with actually including a version of Apple’s OSX in it. This means access to applications like iCal, iTunes, Safari (web browsing), iChat, email client (don’t recall its name), etc. With a maximum amount of 8GB of storage, it’s also very good to completely replace the old iPod.

It amazes me also in this phone the fact that it has no buttons. There’s a big wide screen with which the user interacts by simply using the fingers. Also very interesting, imagine you’re viewing a landscape image. Rotate the phone and it will automatically rotate the screen so you can see the picture in its full size. The phone also has other sensors, like detecting the luminosity features in the environment and adjusting the screen’s brightness accordingly.

Advertisements

C pointer arithmetic weirdness

January 7, 2007

Here’s an interesting example of the uniformity inherent to C pointer arithmetic and vector indexing. Will this piece of code work?

int v[10]; //let's assume it is initialized
int elem = 3[v];

It turns out that yes, it’s valid code. Any good C compiler (like GCC) should accept this. This is explained with a set of equalities:

v[3] == *(v + 3) == *(3 + v) == 3[v]