[C], respectively, by the language standard method, and the output pointer address of the array method of the method all elements

#include<stdio.h>
int main()
{
    int arr[5] = { 11,12,13,14,15 };
    int i, * p;
    printf("下标法:\n");
    for (i = 0; i < 10; i++)
        printf("arr[%d]=%d ", i,arr[i]);
    printf("\n 地址法:\n");
    for (i = 0; i < 10; i++)
        printf("arr[%d]=%d ", i, *(arr+i));
    printf("\n 指针法:\n");
    for (p=arr,i = 0; i < 10; i++)
        printf("arr[%d]=%d ", i, *(p+i));
    return 0;
}

   

Guess you like

Origin www.cnblogs.com/HGNET/p/11973259.html