Question:
Why is the address displayed and not numbers?
here is an example:
#include <iostream>
using namespace std;
int main(void)
{
int x,y;
int numbers[10][10] =
{{1,2,3,2,7,1,8,1,6},
{4,7,4,2,8,9,2,5,8},
{4,9,3,3,6,2,8,4,2},
{1,2,3,6,2,6,8,2,1}};
for(x = 0;x < 10;x++){
cout << *(numbers + x);
for(y = 0;y < 10;y++){
cout << *(numbers + y);
}
}
return 0;
}
Answer:
-
numbers
is of typeint [10][10]
- In this context, the type
numbers
is implicitly converted to typeint (*)[10]
- The type
numbers + i
is alsoint (*)[10]
- Accordingly, the type
*(numbers + i)
isint [10]
- In this context, type
int [10]
is implicitly converted to typeint *
- It is this
int *
that you output. That's why the address is displayed.
In other words, in your example, the address is displayed for the same reason that the address in
int a[10];
std::cout << a << std::endl;