Solution for Exercise 19-18
ex1918
#include <stdio.h> int main() { char *fruit[] = { "watermelon", "banana", "pear", "apple", "coconut", "grape", "blueberry" }; int x; for(x=0;x<7;x++) { putchar(**(fruit+x)); putchar('\n'); } return(0); }
Output
w
b
p
a
c
g
b
Notes
The first letter of each string is output. The expression **(fruit+x)
represents a character, not a string. If you keep in mind that *(fruit+x)
is the memory location of the string, the initial *
is reading the contents of that location, a character.
Copyright © 1997-2024 by QPBC.
All rights reserved