fork download
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<stdlib.h>
  4. int member(char *,struct cell *);/*条件2*/
  5.  
  6. struct cell{/*条件1*/
  7. char animal[20];
  8. struct cell *next;
  9. };
  10.  
  11. int main(){
  12. struct cell *listhead;
  13. char animal[20];
  14. listhead = NULL;
  15.  
  16. struct cell ani1;
  17. listhead.next = &ani1;
  18. ani1.animal[20] = "rat";
  19.  
  20. struct cell ani2;
  21. ani1.next = &ani2;
  22. ani2.animal[20] = "cat";
  23.  
  24. struct cell ani3;
  25. ani2.next = &ani3;
  26. ani3.animal[20] = "dog";
  27.  
  28. struct cell ani4;
  29. ani3.next = &ani4;
  30. ani4.animal[20] = "elephant";
  31.  
  32. struct cell ani5;
  33. ani4.next = &ani5;
  34. ani5.animal[20] = "horse";
  35.  
  36. struct cell ani6;
  37. ani5.next = &ani6;
  38. ani6.animal[20] = "bat";
  39.  
  40. struct cell ani7;
  41. ani6.next = &ani7;
  42. ani7.animal[20] = "hamster";
  43. ani7.next = NULL;
  44.  
  45. while(strcmp(animal,"00") != 0){
  46. char animal;
  47. printf("動物名を英語で入力してください(00で終了)-->");
  48. scanf("%c",&animal){
  49. if(member(*animal,*next) = 1){
  50. printf("%cは存在します。\n",animal);
  51. }else if(member(*animal,*next) = 0){
  52. printf("%cは存在しません。\n",animal);
  53. }
  54. if(strcmp(animal,"00") = 0){
  55. printf("終了します。\n");
  56. return 0;
  57. }
  58. }
  59. }
  60.  
  61.  
  62. int member(char *animal,struct cell *next){
  63. if(*animal = &cell1 ){
  64. return 1;
  65. }
  66. else if(*animal = &cell2){
  67. return 1;
  68. }else if(*animal = &cell3){
  69. return 1;
  70. }else if(*animal = &cell4){
  71. return 1;
  72. }else if(*animal = &cell5){
  73. return 1;
  74. }else if(*animal = &cell6){
  75. return 1;
  76. }else if(*animal = &cell7){
  77. return 1;
  78. }else{
  79. return 0;
  80. }
  81. }
  82.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:17: error: request for member ‘next’ in ‘listhead’, which is of non-class type ‘cell*’
prog.cpp:18: error: invalid conversion from ‘const char*’ to ‘char’
prog.cpp:22: error: invalid conversion from ‘const char*’ to ‘char’
prog.cpp:26: error: invalid conversion from ‘const char*’ to ‘char’
prog.cpp:30: error: invalid conversion from ‘const char*’ to ‘char’
prog.cpp:34: error: invalid conversion from ‘const char*’ to ‘char’
prog.cpp:38: error: invalid conversion from ‘const char*’ to ‘char’
prog.cpp:42: error: invalid conversion from ‘const char*’ to ‘char’
prog.cpp:48: error: expected `;' before ‘{’ token
prog.cpp:81: error: expected `}' at end of input
prog.cpp:81: error: expected `}' at end of input
prog.cpp:81: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result
stdout
Standard output is empty