| string-array-alternative.c - Programmet med alternativ array erklæring. | Lektion 7 - slide 24 : 26 Program 3 |
#include <stdio.h>
int main(void) {
/* char *numbers[] = {"one", "two", "three"}; */
char numbers[][6] = {"one", "two", "three"};
char ch1, ch2, ch3, ch4;
int i;
ch1 = **numbers;
ch2 = numbers[0][0];
ch3 = *(*(numbers+1) + 1);
ch4 = numbers[2][2];
printf("ch1 = %c, ch2 = %c, ch3 = %c, ch4 = %c\n", ch1, ch2, ch3, ch4);
/* Printing 18 characters */
for(i=0; i < 18; i++)
printf("%c", *(&numbers[0][0] + i));
printf("\n");
/* Printing 3 strings */
for(i=0; i < 3; i++)
printf("%s", numbers[i]);
printf("\n");
return 0;
}