파일 입출력 관련.
무들
질문 제목 : 파일 입출력 관련이용..텍스트파일 2개를 받아서 하나로 출력하는것.질문 내용 :
#includestdio.h
#includestdlib.h
#define n 1000
int tot;
struct ex
{
int hak;
char name[8];
char sex[2];
int birth;
int tall;
float weigth;
};
void scan(struct ex a[])
{
int i=0, res = 0;
file *fp;
fp = fopen(c:\\input_a.txt,r);
if (fp == null)
printf(input_a.txt open error!!!\n);
while(1){
res = fscanf(fp,%d %s %s %d %d %f,&a[i].hak, a[i].name, a[i].sex,
&a[i].birth, &a[i].tall, &a[i].weigth);
if(res==eof)
break;
i++;
}
tot = i;
fclose(fp);
}
void print(struct ex a[])
{int i =0;
printf(----------------------------------------------------------------------------------\n);
printf(n 학 번 성 명 반 성별 생년월일 나이 신장 체중:표준 체지량 체지율 결 과\n);
printf(----------------------------------------------------------------------------------\n);
for(i=0; itot; i++)
{
printf(%d %s %s %d %d %1.1f,a[i].hak, a[i].name, a[i].sex,
a[i].birth, a[i].tall, a[i].weigth);
printf(\n);
}
}
void main()
{
struct ex data1[n],data2[n];
scan(data1);
scan(data2);
print(data2);
}여기서요 일단 a 하나는 출력이 됩니다.
근데 제가 a,b 두개를 출력 해야해서요
근데 두개를 출력하려면 어찌해야하나요 ㅠ..
a반
n 학 번 성 명 반 성별 생년월일 나이 신장 체중:표준 체지량 체지율 결 과
b반
n 학 번 성 명 반 성별 생년월일 나이 신장 체중:표준 체지량 체지율 결 과이렇게 출력 되고
merge 정렬 시킨후에 a,b반 통합 출력 되게 해야하는데요..
어떻게 해야할까요. ㅠ 도와주세요
최종은
n 학 번 성 명 반 성별 생년월일 나이 신장 체중:표준 체지량 체지율 결 과
이렇게 나오면서 a,b반 합쳐서 나오게 해야해용. ㅠ