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