Tuesday, April 6, 2010

There is one step from hate to love...

OK guys now rise your hands who love pointers!
No one? Really?
Then lets do the work-through!

#include
int main(){
int i;
int j;
int a[5]={1,2,3,4,5};
int b[3][5]={
{1,2,3,4,5},
{6,7,8,9,10},
{11,12,13,14,15}
};
printf("%d\n", *a); //Try to find two differences
printf("%d\n", **b); //in those two lines.....No rush, take your time :-)
return 0;
}
Now look to the result:
1
1
Now you know that name of array is a pointer to the first member stored
in the array, but if it is two dimensional array then name of the array
is a pointer to pointer to the data stored in first member of the array.
And if you want to scary somebody you can print something like *************c.
But it is deep night and I will afraid to do something like that.
Ok ok I know you don't feel good about me already. But wait a minute I didn't
promise that you going to love pointers! I just said that "There is one step
from hate to LOVE". Sorry there is no magic here...
Magic is here: Punk Magician
And you gonna LOVE it :-)

No comments:

Post a Comment