fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. typedef struct{
  6. char name[15];
  7. bool BC;
  8. bool NC;
  9. bool CT;
  10. bool NS;
  11. bool NM;
  12. bool HL;
  13. bool NL;
  14. }school;
  15.  
  16. int main(void){
  17. int n;
  18. scanf("%d",&n);
  19. school *ptr=(school *)malloc(sizeof(school)*n);
  20. for(int i=0;i<n;i++){
  21. char msg[36]="";
  22. gets(msg);
  23. char *token=strtok(msg," ");
  24. strcpy((*ptr).name,token);
  25. //puts(ptr->name);
  26. while(token!=NULL){
  27. token=strtok(NULL," ");
  28. //puts(token);
  29. if(!strcmp(token,"BC"))
  30. (*ptr).BC=1;
  31. else if(!strcmp(token,"NC"))
  32. (*ptr).NC=1;
  33. else if(!strcmp(token,"CT"))
  34. (*ptr).CT=1;
  35. else if(!strcmp(token,"NS"))
  36. (*ptr).NS=1;
  37. else if(!strcmp(token,"NM"))
  38. (*ptr).NM=1;
  39. else if(!strcmp(token,"HL"))
  40. (*ptr).HL=1;
  41. else if(!strcmp(token,"NL"))
  42. (*ptr).NL=1;
  43. }
  44. ptr++;
  45. }
  46. return 0;
  47. }
  48.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:7: error: expected specifier-qualifier-list before ‘bool’
prog.c: In function ‘main’:
prog.c:21: error: ‘for’ loop initial declaration used outside C99 mode
prog.c:31: error: ‘school’ has no member named ‘BC’
prog.c:33: error: ‘school’ has no member named ‘NC’
prog.c:35: error: ‘school’ has no member named ‘CT’
prog.c:37: error: ‘school’ has no member named ‘NS’
prog.c:39: error: ‘school’ has no member named ‘NM’
prog.c:41: error: ‘school’ has no member named ‘HL’
prog.c:43: error: ‘school’ has no member named ‘NL’
prog.c:18: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
prog.c:23: warning: ignoring return value of ‘gets’, declared with attribute warn_unused_result
stdout
Standard output is empty