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;
}