fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. char birds[] =
  6. {
  7. [0] = "a",
  8. [1] = "b",
  9. [2] = "c",
  10. [3] = "d",
  11. [4] = "e",
  12. [5] = "f",
  13. [6] = "g",
  14. [7] = "h"
  15. };
  16. int birdfound;
  17. int i;
  18. printf("Enter bird:");
  19. scanf("%c", &birdfound);
  20. //printf("%c", birdfound);
  21. for(i=0; i<8; i++)
  22. {
  23. //printf("Y");
  24. if(birdfound == birds[i]){
  25. printf("Bird in array, found at position %d\n", i);
  26. }
  27. }
  28. return 0;
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:7:15: error: initialization makes integer from pointer without a cast [-Werror=int-conversion]
         [0] = "a",
               ^~~
prog.c:7:15: note: (near initialization for ‘birds[0]’)
prog.c:8:15: error: initialization makes integer from pointer without a cast [-Werror=int-conversion]
         [1] = "b",
               ^~~
prog.c:8:15: note: (near initialization for ‘birds[1]’)
prog.c:9:15: error: initialization makes integer from pointer without a cast [-Werror=int-conversion]
         [2] = "c",
               ^~~
prog.c:9:15: note: (near initialization for ‘birds[2]’)
prog.c:10:15: error: initialization makes integer from pointer without a cast [-Werror=int-conversion]
         [3] = "d",
               ^~~
prog.c:10:15: note: (near initialization for ‘birds[3]’)
prog.c:11:15: error: initialization makes integer from pointer without a cast [-Werror=int-conversion]
         [4] = "e",
               ^~~
prog.c:11:15: note: (near initialization for ‘birds[4]’)
prog.c:12:15: error: initialization makes integer from pointer without a cast [-Werror=int-conversion]
         [5] = "f",
               ^~~
prog.c:12:15: note: (near initialization for ‘birds[5]’)
prog.c:13:15: error: initialization makes integer from pointer without a cast [-Werror=int-conversion]
         [6] = "g",
               ^~~
prog.c:13:15: note: (near initialization for ‘birds[6]’)
prog.c:14:15: error: initialization makes integer from pointer without a cast [-Werror=int-conversion]
         [7] = "h"
               ^~~
prog.c:14:15: note: (near initialization for ‘birds[7]’)
prog.c:19:13: error: format ‘%c’ expects argument of type ‘char *’, but argument 2 has type ‘int *’ [-Werror=format=]
     scanf("%c", &birdfound);
             ^
cc1: all warnings being treated as errors
stdout
Standard output is empty