arrays/array-intro-3-pointers.c - Et tilsvarende program - med pointer tilgang til elementerne. | Lektion 9 - slide 14 : 30 Program 2 |
#include <stdio.h> #define TABLE_SIZE 11 int main(void) { /* Declarations: */ double table[TABLE_SIZE], *tp; /* Initialization: */ for(tp = table; tp < table + TABLE_SIZE; tp++) *tp = (double)(2 * (tp - table)); /* Access - printing: */ for(tp = table; tp < table + TABLE_SIZE; tp++) printf("%f\n", *tp); printf("\n"); return 0; }