fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. short arr[5] = {1, 2, 3, 4, 5};
  6. short* a = arr; // указатель на int
  7. short (*b)[5] = &arr; // указатель на int[5]
  8. cout << "sizeof arr: " << sizeof(arr) << endl;
  9. cout << "sizeof a: " << sizeof(a) << endl;
  10. cout << "sizeof b: " << sizeof(b) << endl;
  11. cout << "sizeof *a: " << sizeof(*a) << endl;
  12. cout << "sizeof *b: " << sizeof(*b) << endl;
  13. for (int i=0; i < 5; ++i) {
  14. cout << arr[i] << " " << a[i] << " " << (*b)[i] << endl;
  15. }
  16. return 0;
  17. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
sizeof arr: 10
sizeof a: 4
sizeof b: 4
sizeof *a: 2
sizeof *b: 10
1 1 1
2 2 2
3 3 3
4 4 4
5 5 5