/*數組
#define NAMESIZE 30ide
struct {
char name[NAMESIZE];
long number;
short department;
short scores[10];//保存學生成績的數組
}student;//保存一個學生信息的結構code
short *pscores;//保存學生成績的數組it
int main(int argc, char argv[])
{
FILE fpstudents;//已經存在的學生信息文件
FILE *fpscores;//未存在的學生信息文件io
if(argc<2) { printf("usage:%s sourcefile destfile\n",argv[0]); return 1; } if((fpstudents=fopen(argv[1],"r"))==NULL)//打開學生信息文件 { printf("Open sourcefile %s failed!",argv[1]); return 2; } if((fpscore=fopen(argv[2],"w"))==NULL)//建立學生成績文件 { printf("Create destfile %s failed!",argv[2]); return 3; } while(fread(&student,sizeof(student),1,fpstudents)==1)//將成績的前3項寫入文件中 { pscores=student.scores; if(fwrite(&pscores,sizeof(short),3,fpscore)!=3) printf("Error in writing file.\n"); return 4; } return 0;
}class