구조체 성적관리프로그램좀 봐주세요 급합니다ㅠ.ㅠ
봄여우
질문 제목 : 구조체 성적관리프로그램좀 봐주세요 급합니다ㅠ.ㅠ파일뒤에다가 써주고 그런다음 2번을 누르면 파일이 출력되야하는데
출력이안되네요ㅠㅠㅠ 어디가 잘못되었는지좀 잘 봐주세요ㅠㅠ급해요..제가초보라..질문 내용 :
#include stdio.h
#include string.h//문자열 함수를 사용하기 위해
struct profile
{
char name[50];
int hak;
char tel[50];
};
int main()
{
struct profile ps[30];
int num;
file *ifp, *ofp;
int i, cnt = 0;
printf(==========학생관리 프로그램==========\n);
printf(1. 학생 목록 입력\n);
printf(2. 학생 목록 출력\n);
printf(3. 종료\n);
printf(번호를 입력하세요 - );
scanf(%d,&num);
switch(num)
{
case 1:
ofp = fopen(data.txt,a);
if(ofp==null) {
printf(파일 개방 실패\n);
return 1;
}
printf(학생 이름을 입력하세요 : );
scanf(%s,ps[50].name);
printf(학번을 입력하세요 : );
scanf(%d,ps[50].hak);
printf(전화번호를 입력하세요 : );
scanf(%s,ps[50].tel);
printf(등록되었습니다.\n);
fprintf(ofp,%s %d %s\n,ps[50].name,&ps[50].hak,ps[50].tel);
fclose(ofp);
case 2:
ifp = fopen(data.txt,r);
if(ifp==null) {
printf(파일 개방 실패\n);
return 1;
}
while(feof(ifp))
{
fscanf(ifp,%s %d %s,ps[cnt].name,&ps[cnt].hak,ps[cnt].tel);
cnt++;
}
printf(|=============학생 관리============|\n);
printf(| 이 름 | 학 번 | 전 화 번 호 |\n);
for(i=0; icnt; i++)
{
printf(| %3d | %2d | %2d |,ps[i].name, ps[i].hak, ps[i].tel);
}
printf(\n);
printf(|==================================|\n);
fclose(ifp);
case 3:
printf(프로그램을 종료합니다.\n);
break;
default:
printf(입력하신 번호가 없습니다.\n);
}
return 0;
}