codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <stdlib.h> #include <stdio.h> #define NAME_LEN 072 #define SCORE_LEN 5 #define LEN 30 enum {KOKUGO, SYAKAI, SUUGAKU, RIKA, EIGO}; const char * SUBJECTS[] = {"国語", "社会", "数学", "里香", "英語"}; typedef struct { char name[NAME_LEN]; int score[SCORE_LEN]; } ITEM; int main(void) { int i, j; ITEM items[LEN]; FILE *fp; char filename[1000]; printf("保存したいファイル名:"); scanf("%s", filename); if (!(fp = fopen(filename, "rb"))) { fprintf(stderr, "fileopenerrrrrrrrrrrr\n"); return 1; } for (i = 0; i < LEN; i++) { if (!fread((void *)(items + i), sizeof ITEM, 1, fp)) break; } for (j = 0; j < i; j++) { printf("%sさんの成績 国語:%2d点 社会:%2d点 数学%2d 里香:%2d点 英語:%2d点\n", items[j].name, items[j].score[KOKUGO], items[j].score[SYAKAI], items[j].score[SUUGAKU], items[j].score[RIKA], items[j].score[EIGO]); } return 0; }
Private
[
?
]
Run code
Submit