これは、大規模なプログラムで使用する前に、fopen および同様の構文のコツをつかむために主に作成されたプログラムからのものです。したがって、プログラムが実行しようとしている唯一のことは、ファイル (scores.dat) を開き、そのファイルのデータを読み取り、それを配列に割り当て、配列を出力することです。
これは、エラーが発生したコードのセグメントです。
int scores[13][4];
FILE *score;
score = fopen("scores.dat", "r");
fscanf("%d %d %d %d", &scores[0][0], &scores[0][1], &scores[0][2], &scores[0][3]);
printf("%d &d %d %d", scores[0][0], scores[0][1], scores[0][2], scores[0][3]);
fclose(score);
コンパイルすると、次のエラーが表示されます。
text.c: In function 'main':
text.c:15: warning: passing argument 1 of 'fscanf' from incompatible pointer type
text.c:15: warning: passing argument 2 of 'fscanf' from incompatible pointer type
どうすれば修正できますか?
重要な場合、score.dat は次のようになります。
88 77 85 91 65 72 84 96 50 76 67 89 70 80 90 99 42 65 66 72 80 82 85 83 90 89 93
98 86 76 85 99 99 99 99 99 84 72 60 66 50 31 20 10 90 95 91 10 99 91 85 80