📜  使用指针访问一维数组的元素 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:36.758000             🧑  作者: Mango

代码示例1
#include

int main(){

    int arr[] = {1,3,4,5,6,7,8};
    int *ptr = &arr; //storing address of the first element in array in the ptr

      //accessing the elements of the array using ptr
    for(int i=0;i<7;i++)
        printf("%d ",*(ptr+i));
      //here i represents the value to be added to the base address
    return 0;
}