본문내용
cord(s) Created\n");
fprintf(Prof,"%s %s %s\n",ch1,ch2,ch3);
i=fclose(Prof);
if(i!=0)
{
printf("file close error\n");
return 1;
}
}
else if(strcmp(menu,"rProf")==0)
{
Prof = fopen("Prof.txt", "a+");
if(Prof==NULL)
{
printf("file open error!\n");
return 1;
}
i=0;
while(1) {
ck=fscanf(Prof,"%s %s %s\n",ch1,ch2,ch3);
if(ck==EOF)
break;
printf("%s %s %s\n",ch1, ch2, ch3);
i++;
}
printf("%d Record(s) Read\n",i);
i=fclose(Prof);
if(i!=0) {
printf("file close error\n");
return 1;
}
}
else if(strcmp(menu,"cRelation")==0)
{
Student = fopen("Student.txt", "a+");
Prof = fopen("Prof.txt", "a+");
Relation = fopen("Relation.txt", "a+");
if(Student==NULL || Prof==NULL || Relation==NULL)
{
printf("file open error!\n");
return 1;
}
scanf("%s %s",num1, num2);
while(1)
{
ck = fscanf(Student,"%s %s %s\n",ch1, ch2, ch3);
if(ck==EOF)
break;
else if(strcmp(ch1,num1)==0)
break;
}
while(1)
{
ck = fscanf(Prof,"%s %s %s\n",ch4, ch5, ch6);
if(ck==EOF)
break;
else if(strcmp(ch4,num2)==0)
break;
}
if(strcmp(ch1,num1)==0 && strcmp(ch4,num2)==0)
{
fprintf(Relation,"%s %s %s %s %s\n", ch1, ch2, ch3, ch4, ch5);
printf("1 Record(s) Created\n");
}
i=fclose(Student);
if(i!=0)
{
printf("file close error\n");
return 1;
}
i=fclose(Prof);
if(i!=0)
{
printf("file close error\n");
return 1;
}
i=fclose(Relation);
if(i!=0)
{
printf("file close error\n");
return 1;
}
}
else if(strcmp(menu,"rRelation")==0)
{
Relation = fopen("Relation.txt", "a+");
if(Prof==NULL)
{
printf("file open error!\n");
return 1;
}
i=0;
while(1)
{
ck=fscanf(Relation,"%s %s %s %s %s\n",ch1,ch2,ch3,ch4,ch5);
if(ck==EOF)
break;
printf("%s %s %s %s %s\n",ch1, ch2, ch3, ch4, ch5);
i++;
}
printf("%d Record(s) Read\n",i);
i=fclose(Relation);
if(i!=0)
{
printf("file close error\n");
return 1;
}
}
else
{
printf("error\n");
continue;
}
}
return 0;
}
fprintf(Prof,"%s %s %s\n",ch1,ch2,ch3);
i=fclose(Prof);
if(i!=0)
{
printf("file close error\n");
return 1;
}
}
else if(strcmp(menu,"rProf")==0)
{
Prof = fopen("Prof.txt", "a+");
if(Prof==NULL)
{
printf("file open error!\n");
return 1;
}
i=0;
while(1) {
ck=fscanf(Prof,"%s %s %s\n",ch1,ch2,ch3);
if(ck==EOF)
break;
printf("%s %s %s\n",ch1, ch2, ch3);
i++;
}
printf("%d Record(s) Read\n",i);
i=fclose(Prof);
if(i!=0) {
printf("file close error\n");
return 1;
}
}
else if(strcmp(menu,"cRelation")==0)
{
Student = fopen("Student.txt", "a+");
Prof = fopen("Prof.txt", "a+");
Relation = fopen("Relation.txt", "a+");
if(Student==NULL || Prof==NULL || Relation==NULL)
{
printf("file open error!\n");
return 1;
}
scanf("%s %s",num1, num2);
while(1)
{
ck = fscanf(Student,"%s %s %s\n",ch1, ch2, ch3);
if(ck==EOF)
break;
else if(strcmp(ch1,num1)==0)
break;
}
while(1)
{
ck = fscanf(Prof,"%s %s %s\n",ch4, ch5, ch6);
if(ck==EOF)
break;
else if(strcmp(ch4,num2)==0)
break;
}
if(strcmp(ch1,num1)==0 && strcmp(ch4,num2)==0)
{
fprintf(Relation,"%s %s %s %s %s\n", ch1, ch2, ch3, ch4, ch5);
printf("1 Record(s) Created\n");
}
i=fclose(Student);
if(i!=0)
{
printf("file close error\n");
return 1;
}
i=fclose(Prof);
if(i!=0)
{
printf("file close error\n");
return 1;
}
i=fclose(Relation);
if(i!=0)
{
printf("file close error\n");
return 1;
}
}
else if(strcmp(menu,"rRelation")==0)
{
Relation = fopen("Relation.txt", "a+");
if(Prof==NULL)
{
printf("file open error!\n");
return 1;
}
i=0;
while(1)
{
ck=fscanf(Relation,"%s %s %s %s %s\n",ch1,ch2,ch3,ch4,ch5);
if(ck==EOF)
break;
printf("%s %s %s %s %s\n",ch1, ch2, ch3, ch4, ch5);
i++;
}
printf("%d Record(s) Read\n",i);
i=fclose(Relation);
if(i!=0)
{
printf("file close error\n");
return 1;
}
}
else
{
printf("error\n");
continue;
}
}
return 0;
}
추천자료
- 리눅스(proc)파일
- FIFO를 이용한 time client-server programming
- 트리(tree)관련 프로그래밍 소스 모음 (C언어)
- cyclic prefix에 대한 C언어 소스분석
- [C++]C언어를 이용한 계산기 소스 및 실행파일
- 라이프니치 수열
- 사칙연산 프로그램 -C소스,C코드
- Crout 법,Crout, C언어 소스 Crout법입니다.
- 이산수학 8장 연습문제 및 프로그래밍
- [API][C언어][소스]테트리스!
- 진수변환 C 프로그램 소스코드
- 몬티 홀 문제
- MFC 벌레 잡기 게임 (BugCatch)
- OS (운영체제) 과목 메시지 큐 구현 소스 및 결과 보고서 (c언어)
소개글