| array-intro-1-pointers.c - Et program hvor tabellen table tilgås via en pointer. | Lektion 6 - slide 15 : 26 Program 4 |
#include <stdio.h>
#define TABLE_SIZE 11
int main(void) {
double table[TABLE_SIZE], *table_ptr = &table[0], *tp;
int i;
for(tp = table_ptr, i=0; tp < &table[TABLE_SIZE]; tp++, i++)
*tp = (double)(2 * i);
for(tp = table_ptr; tp < &table[TABLE_SIZE]; tp++)
printf("%f\n", *tp);
printf("\n");
return 0;
}