KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Do you think what this discussion about memory-map of 2D array is correct? Especially this photo? Can you explain the theory? Suppose we declare a 2D array in C like this: int arr[3][3]={10, 20, 30, 40, 50, 60, 70, 80, 90}; Now, according to this discussion, the memory would be arranged like the following: Now, I have written the following code to test this theory: #include <stdio.h> main() { int arr[3][3]={10, 20, 30, 40, 50, 60, 70, 80, 90}; printf(" arr==%d\n", arr); printf(" &arr[0]==%d\n", &arr[0]); printf(" arr[0]==%d\n", arr[0]); printf("&arr[0][0]=%d\n", &arr[0][0]); printf(" arr[0][0]=%d\n", arr[0][0]); } /* Output: ======== arr ==1245028 &arr[0] ==1245028 arr[0] ==1245028 &arr[0][0]==1245028 arr[0][0]==10 Press any key to continue... */ Why the first 4 outputs are same?
Tags (comma-separated)
Save Edits
Cancel