arrchar.c 845 B

12345678910111213141516171819202122232425262728
  1. // arrchar.c -- array of pointers, array of strings
  2. #include <stdio.h>
  3. #define SLEN 40
  4. #define LIM 5
  5. int main(void)
  6. {
  7. const char *mytalents[LIM] = {
  8. "Adding numbers swiftly",
  9. "Multiplying accurately", "Stashing data",
  10. "Following instructions to the letter",
  11. "Understanding the C language"
  12. };
  13. char yourtalents[LIM][SLEN] = {
  14. "Walking in a straight line",
  15. "Sleeping", "Watching television",
  16. "Mailing letters", "Reading email"
  17. };
  18. int i;
  19. puts("Let's compare talents.");
  20. printf ("%-36s %-25s\n", "My Talents", "Your Talents");
  21. for (i = 0; i < LIM; i++)
  22. printf("%-36s %-25s\n", mytalents[i], yourtalents[i]);
  23. printf("\nsizeof mytalents: %zd, sizeof yourtalents: %zd\n",
  24. sizeof(mytalents), sizeof(yourtalents));
  25. return 0;
  26. }