ファイルの入出力でstudent構造体の配列は定義しておいて、
どうやって出力すればよいのでしょうか?
教えてください。
#include <stdio.h> #include <stdlib.h> struct student{ int num; char name[20]; int score; }; struct student St[] = {{3,"鈴木三郎",86}, {1,"山田一郎",75}, {14,"高橋十四子",93}, {2,"田中二子",68}}; int main(){ int i; FILE *fp; if((fp=fopen(St[],"r"))==NULL){ printf("file dose not exist!\n"); exit(1); } for(i=0;i<4;i++){ fprintf("%d %s %d\n", St[i].num, St[i].name, St[i].score); } fclose(fp); }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/05 10:25