fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. typedef struct {
  5. int kokugo;
  6. int eigo;
  7. } Seiseki;
  8.  
  9. int main(){
  10. int i, n = 5;
  11. Seiseki *SS;
  12. Seiseki *pt;
  13. SS = (Seiseki *)malloc(sizeof(Seiseki)*n);
  14. if(SS == NULL) return 0;
  15. pt = SS;
  16. for(i=0;i<n;i++){
  17. pt->kokugo = i*10;
  18. pt->eigo = i*5;
  19. //printf("%d,%d\n",SS[i].kokugo,SS[i].eigo);
  20. //printf("%d,%d\n",SS[i]->kokugo,SS[i]->eigo);
  21. //printf("%d,%d\n",pt[i].kokugo,pt[i].eigo);
  22. printf("%d,%d\n",pt[i]->kokugo,pt[i]->eigo);
  23. pt++;
  24. }
  25. free(SS);
  26. return 0;
  27. }
  28.  
Compilation error #stdin compilation error #stdout 0s 5272KB
stdin
5
compilation info
prog.c: In function ‘main’:
prog.c:22:31: error: invalid type argument of ‘->’ (have ‘Seiseki’ {aka ‘struct <anonymous>’})
         printf("%d,%d\n",pt[i]->kokugo,pt[i]->eigo);
                               ^~
prog.c:22:45: error: invalid type argument of ‘->’ (have ‘Seiseki’ {aka ‘struct <anonymous>’})
         printf("%d,%d\n",pt[i]->kokugo,pt[i]->eigo);
                                             ^~
stdout
Standard output is empty