Uses pointer notation to access array element - C Array

C examples for Array:Introduction

Description

Uses pointer notation to access array element

Demo Code

#include <stdio.h>
#define MONTHS 12//from  w  ww. j  a  va 2s.  co  m

int main(void)
{
    int days[MONTHS] = {31,28,31,30,31,30,31,31,30,31,30,31};
    int index;
    
    for (index = 0; index < MONTHS; index++)
        printf("Month %2d has %d days.\n", index +1, *(days + index));   // same as days[index]
    
    return 0;
}

Result


Related Tutorials