Solution for Exercise 19-16

ex1916

#include <stdio.h>

int main()
{
    char *fruit[] = {
        "watermelon",
        "banana",
        "pear",
        "apple",
        "coconut",
        "grape",
        "blueberry"
    };
    int x;

    for(x=0;x<7;x++)
        puts(fruit[x]);

    return(0);
}

Output

watermelon
banana
pear
apple
coconut
grape
blueberry

Notes

* This example shows another way to create an initialized array of strings. Array notation is still used throughout.