실행시키고 내용입력이안되네요^^;도와주세요
로지
질문 제목 : 실행시 입력이안됩니다..질문 요약 :내용 입력이안됩니다 도와주세요 ㅠㅠ질문 내용 :
#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);
}
번호 | 제 목 | 글쓴이 | 날짜 |
---|---|---|---|
2700530 | 전처리문 질문입니다. (1) | 아놀드 | 2025-07-05 |
2700510 | c언어를 어케하면 잘할수 있을까요.. | 연연두 | 2025-07-05 |
2700484 | 두 개가 차이가 뭔지 알려주세요...(소수 찾는 프로그램) (2) | 날위해 | 2025-07-05 |
2700426 | 인터넷 창 띄우는 질문이요 (1) | 정훈 | 2025-07-04 |
2700400 | 원넓이를 계산이요 ㅜㅜ | 천칭자리 | 2025-07-04 |
2700368 | if에 관해서 질문이요... | Orange | 2025-07-04 |
2700339 | 이거 결과값이 왜이런건지.. (4) | 그댸와나 | 2025-07-04 |
2700313 | 파일 읽어서 저장하는데 빈파일일 경우 문재가 발생하네요.. (2) | 크나 | 2025-07-03 |
2700287 | 구조체 동적할당 연습을 하는데 오류가 뜹니다...(해결) (3) | 아련나래 | 2025-07-03 |
2700264 | 문자와 숫자 동시에 입력??? | 글고운 | 2025-07-03 |
2700236 | txt파일로만 쓰고 읽게 하려면 어떻게 해야 하나요..?? (8) | 미국녀 | 2025-07-03 |
2700211 | 전위 연산자 (2) | 어른처럼 | 2025-07-02 |
2700183 | C에서 파일이름을 받고, 그 파일의 사이즈를 출력해줘야하는데 내용이 출력이 안되네요 ;ㅅ; | 피스케스 | 2025-07-02 |
2700150 | 꼭좀 도와주세요ㅠㅠㅠ | 호습다 | 2025-07-02 |
2700095 | 연산문제...질문... | 오빤테앵겨 | 2025-07-01 |
2700070 | while문 , 3의배수 출력하는 프로그램좀 짜주세욤. | 횃불 | 2025-07-01 |
2700041 | 초보인데요 ㅎ 배열안에 배열을 집어넣을수 있나요?? | 헛장사 | 2025-07-01 |
2700012 | 배열// (1) | 전갈자리 | 2025-07-01 |
2699895 | 무한루프에 빠집니다.!! 해결좀부탁드려요 (10) | 선아 | 2025-06-30 |
2699842 | 질문을 너무 많이 하네여.....죄송.... (2) | 해님꽃 | 2025-06-29 |