【发布时间】:2015-07-06 09:28:38
【问题描述】:
看看这个程序。 ptr 如何获取数组中的所有内容?我有点困惑。
#include <stdio.h>
int main()
{
int arr[] = {10, 20, 30, 40, 50, 60};
int *ptr = arr;
// sizof(int) * (number of element in arr[]) is printed
printf("Size of arr[] %d\n", sizeof(arr));
// sizeof a pointer is printed which is same for all type
// of pointers (char *, void *, etc)
printf("Size of ptr %d", sizeof(ptr));
return 0;
}
【问题讨论】:
标签: c++