fork(1) download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. char *p[][2] =
  5. {
  6. "Red Delicious", "red",
  7. "Golden Delicious", "yellow",
  8. "Wineasp", "red",
  9. "Gala", "reddish orange",
  10. "Lodi", "green",
  11. "Mutsu", "yellow",
  12. "Cortland", "read",
  13. "Jonathan", "red",
  14. "", ""
  15. };
  16.  
  17. int main() {
  18. int i;
  19. char apple[80];
  20.  
  21. printf("Enter name of apple: ");
  22. gets(apple);
  23.  
  24. for(i = 0; *p[i][0]; i++)
  25. {
  26. if(!strcmp(apple, p[i][0])) printf("%s is %s\n", apple, p[i][1]); // if(!strcmp(apple, *p[i][0])) printf("%s is %s\n", apple, *p[i][1]); keno noy?
  27. }
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 2012KB
stdin
Lodi
stdout
Enter name of apple: Lodi is green