Tuesday, August 02, 2005

C Quiz Part II -- Pointers into Arrays

Q. What is the output of this program?
int f(int b[][2]){ return ++b[0][0]; }
int g(int b[][2]){ return ++b,b[0][0]; }
int h(int b[][2]){ return (++b,b[0][0]); }
int i(int b[][2]){ return (1+b,b)[0][0]; }
main(){
    int a[][2]={101,201,301,401};
    printf("f=%d\n",f(a)); 
    printf("g=%d\n",g(a)); 
    printf("h=%d\n",h(a)); 
    printf("i=%d\n",i(a)); 
}    
Further reading.

1 Comments:

Anonymous Anonymous said...

i like what i have read on the programmer notes . can u sent me some more.mla at graffiti dot net

11:59 AM  

Post a Comment

<< Home