c中数组声明的指针变量

时间:2014-10-11 05:33:35

标签: c

What's the difference between

int a[10] = {0,1,2,3,4,5,6,7,8,9};
int *a_ptr = a;

and

int a[10] = {0,1,2,3,4,5,6,7,8,9};
int *a_ptr = &a;

我在我的代码中尝试了它们,我得到了相同的结果。 但我不确定它们是否相同。

Here is my code:
#include <stdio.h>

int main(void) {
int i;
int n[10] = {0,1,2,3,4,5,6,7,8,9};
int *nptr = n;
for (i = 0; i < 10; i++)
printf("%d\n", nptr[i]);

return 0;
}

0 个答案:

没有答案
相关问题