실행시키고 내용입력이안되네요^^;도와주세요
로지
질문 제목 : 실행시 입력이안됩니다..질문 요약 :내용 입력이안됩니다 도와주세요 ㅠㅠ질문 내용 :
#include stdio.h
#include string.h
void input(void);
void output(void);
void cur_seek(void);
struct S {
char dept[20];
char name[20];
char telno[15];
int age;
char addr[30];
};
int main(void)
{
int choice;
while(1)
{
do{
puts(\n====고객관리프로그램====);
printf(1) 회원정보 등록 \n);
printf(2) 회원정보 출력 \n);
printf(3) 임의 접근\n);
printf(4) 종료 \n);
puts(-----------------------);
printf(\n 선택하세요 ? );
scanf(%d%*c, &choice);
}while(choice!=4);
switch(choice)
{
case 1 : input(); break;
case 2 : output(); break;
case 3 : cur_seek(); break;
case 4 : exit(0);
}
}
return 0 ;
}
void input(void)
{
struct S temp;
FILE *fp;
if((fp=fopen(student.txt, a+))==NULL)
{
printf(file open error. \n);
exit(1);
}
// 데이터 입력
while(1)
{
printf(성명 ?(종료:end) );
gets(temp.name);
if(!strcmp(temp.name, end))
break;
printf(부서 ? );
gets(temp.dept);
printf(전화번호 ? );
gets(temp.telno);
printf(나이 ? );
scanf(%d%*c, &temp.age);
printf(주소 ? );
gets(temp.addr);
fwrite(&temp, sizeof(temp), 1, fp);
}
fclose(fp);
}
//파일 순차접근
void output(void)
{
struct S temp;
FILE *fp;
int cn=0;
if((fp=fopen(student.dat, r))==NULL)
{
printf(file open error. \n);
exit(1);
}
printf(=======================================\n);
printf(No 부서 성명 전화번호 나이 주소 \n);
printf(=======================================\n);
while(1)
{
if(fread(&temp, sizeof(temp), 1, fp)!=1)
break;
printf(%d, %5s %5s %8s %4d %10s\n,++cn,temp.dept,
temp.name, temp.telno, temp.age, temp.addr);
}
fclose(fp);
}
//파일 임의접근
void cur_seek(void)
{
struct S temp;
FILE *fp;
int location, rec, find;
if((fp=fopen(student.dat, r))==NULL)
{
printf(file open error. \n);
exit(1);
}
fseek(fp, 0, SEEK_END);
location=ftell(fp);
rec=location/sizeof(struct S);
printf(레코드는 %d 개 입니다. \n, rec);
do{
printf(접근할 레코드 위치 ? );
scanf(%d, &find);
}while(find0 || findrec);
fseek(fp, (find-1)*sizeof(struct S), SEEK_SET);
fread(&temp, sizeof(temp), 1, fp);
printf(%5s %5s %8s %4d %10s\n,temp.dept, temp.name,
temp.telno, temp.age, temp.addr);
fclose(fp);
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2655440 | test파일이 안 되요. (2) | 리라 | 2024-05-19 |
2655416 | 고수님들 도움이 절실합니다. (2) | 세리 | 2024-05-19 |
2655361 | 엔터 입력받을때까지 기다리는 getchar (1) | 큰모음 | 2024-05-19 |
2655328 | 함수에서 포인터 (3) | 모아 | 2024-05-18 |
2655299 | 아이콘바꾸는법..? | 소 | 2024-05-18 |
2655271 | scanf 입력받으면 쭉 실행되는.. (5) | ComeOn | 2024-05-18 |
2655184 | 이 세개 프로그램좀 해결해주실.... 고수님들???? (3) | 말달리자 | 2024-05-17 |
2655129 | 다차원 배열 원소들 주소계산하는거 질문이요~ | 터전 | 2024-05-17 |
2655103 | AVRstudio MoveAxis. MoveLine 함수질문 | 앨버트 | 2024-05-16 |
2655072 | 콘솔창의 위치와 크기를 정하고 싶습니다. | 딥레드 | 2024-05-16 |
2655044 | 자료구조랑 online judge site에 대해서 질문있습니다... (1) | 뽀송뽀송 | 2024-05-16 |
2655016 | 별찍기 문제 중 이해안되는 부분이 있어요... | 도전중 | 2024-05-16 |
2654986 | 입력받은 성적을 배열에 저장하기 (3) | 안녕나야 | 2024-05-15 |
2654959 | ===========-이런거 미리 지정하는법 (1) | 김자영 | 2024-05-15 |
2654930 | 도와주십시요 ㅜㅜ 자료구조 ㅜㅜ | 도널드 | 2024-05-15 |
2654881 | PID 모듈 검색 부분 질문합니다 . | 이름없음 | 2024-05-14 |
2654850 | 조건에 만족하는 다음 수를 찾고 싶습니다. | 초엘 | 2024-05-14 |
2654790 | 두파일간 byte단위 txt파일 복사 中 | 슬찬 | 2024-05-14 |
2654768 | 사전만들기 입니다. | 여우By | 2024-05-13 |
2654716 | c언어 고수님들 답좀적어주세요 급합니다 ㅠㅠ | 한말글 | 2024-05-13 |