kistories
2009-10-25 22:28:22 UTC
Here's my program:
• #include
• int main() {
• float *pf;
• float m[][3]={ {0.1, 0.2, 0.3},
• {0.4, 0.5, 0.6},
• {0.7, 0.8, 0.9}};
• printf("%d \n",sizeof(m));
• pf=m[1];
• printf("%f %f %f \n",*pf, *(pf+1), *(pf+2));
• printf("%f %f %f \n",*pf, *(pf++), *(pf++));
• }
So the first print line prints out 0.4,0.5,0.6, which I'd expect. After all pf goe to the base element of [1] which is 0.4, then prints the next two elements.
But what is going on in the second line? It prints 0.6, 0.5,0.4. Why? Is it reading backwards? Can someone explain this theoretically what is going on here?