#include <stdio.h>
#include <stdlib.h>
typedef struct {
int kokugo;
int eigo;
} Seiseki;
int main(){
int i, n = 5;
Seiseki *SS;
Seiseki *pt;
SS
= (Seiseki
*)malloc(sizeof(Seiseki
)*n
); if(SS == NULL) return 0;
pt = SS;
for(i=0;i<n;i++){
pt->kokugo = i*10;
pt->eigo = i*5;
//printf("%d,%d\n",SS[i].kokugo,SS[i].eigo);
//printf("%d,%d\n",SS[i]->kokugo,SS[i]->eigo);
//printf("%d,%d\n",pt[i].kokugo,pt[i].eigo);
printf("%d,%d\n",pt
[i
]->kokugo
,pt
[i
]->eigo
); pt++;
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCnR5cGVkZWYgc3RydWN0IHsKICAgIGludCBrb2t1Z287CiAgICBpbnQgZWlnbzsKfSBTZWlzZWtpOwoKaW50IG1haW4oKXsKICAgIGludCBpLCBuID0gNTsKICAgIFNlaXNla2kgKlNTOwogICAgU2Vpc2VraSAqcHQ7CiAgICBTUyA9IChTZWlzZWtpICopbWFsbG9jKHNpemVvZihTZWlzZWtpKSpuKTsKICAgIGlmKFNTID09IE5VTEwpIHJldHVybiAwOwogICAgcHQgPSBTUzsKICAgIGZvcihpPTA7aTxuO2krKyl7CiAgICAgICAgcHQtPmtva3VnbyA9IGkqMTA7CiAgICAgICAgcHQtPmVpZ28gPSBpKjU7CiAgICAgICAgLy9wcmludGYoIiVkLCVkXG4iLFNTW2ldLmtva3VnbyxTU1tpXS5laWdvKTsKICAgICAgICAvL3ByaW50ZigiJWQsJWRcbiIsU1NbaV0tPmtva3VnbyxTU1tpXS0+ZWlnbyk7CiAgICAgICAgLy9wcmludGYoIiVkLCVkXG4iLHB0W2ldLmtva3VnbyxwdFtpXS5laWdvKTsKICAgICAgICBwcmludGYoIiVkLCVkXG4iLHB0W2ldLT5rb2t1Z28scHRbaV0tPmVpZ28pOwogICAgICAgIHB0Kys7CiAgICB9CiAgICBmcmVlKFNTKTsKICAgIHJldHVybiAwOwp9Cg==
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);
^~