I'm trying to initialize int array in struct but when I take a value from scanf then access to values it's give me warning: format specifies type 'int' but the argument has type 'int *' [-Wformat] error. This is the my code:
struct maclar {
int macNo[40];
int evSahibi[40];
int deplasman[40];
} mac[40];
void verileriAl(FILE *mp) {
for (int i = 0; fscanf(mp,"%d %d %d",
mac[i].macNo, mac[i].evSahibi, mac[i].deplasman) != -1; i++) {
........codes here .....
}
}
main() {
FILE *mp = fopen("maclar.txt", "r");
verileriAl(mp);
printf("%d\n", mac[0].macNo); //give me warning and wrong value
}
main()when run on an OS, only has 2 valid and one optional signature. All those signatures have aintreturn type. With out a OS, the only valid return type isvoidfopen()always check (!=NULL) the returned value to assure the operation was successful.