while 밖에서는 잘 작동하는데 while 안에서는 에러가 납니다
은송이
질문 제목 : while 밖에서는 잘 작동하는데 while 안에서는 에러가 납니다질문 요약 :구조체를 이용해 주소록 보기, 추가, 삭제, 검색 기능을 갖는 프로그램을 작성하는데 이해되지 않는 에러가 나고있습니다.
이유가 무엇이고 어떻게 고치면 되는건가요?
질문 내용 :
아래와 같은 코딩을 짰는데,
#includestdio.h
#includestring.h
struct book{
char name[15];
char cell[18];
char addr[100];
char birth[15];
};
void searchlist(book book[], char *name, int count);
int main(){
book book[10];
int i, count = 0;
char searchname[10];
//test :while밖에서 구조체 배열 첫번째 데이터를 입출력 해봤습니다. 정상작동!
scanf(%s %s %s %s, book[count].name, book[count].cell, book[count].addr, book[count].birth);
printf(%s %s %s %s\n, book[count].name, book[count].cell, book[count].addr, book[count].birth);
count++;
while(1){
printf(원하는 기능을 입력하세요 : );
scanf(%d, &i);
switch(i){
//하지만 정작 필요한 while, switch 문 안에서 첫번째 데이터를 출력해봤는데 첨부된 그림파일처럼 에러가 발생했습니다.
case 1:
{
printf(이름 전화번호 주소 생일\n);
for(i = 0 ; i count ; i++){
printf(%s %s %s %s, book[count].name, book[count].cell, book[count].addr, book[count].birth);
}
break;
}
//윗 부분이 안되기때문인진 몰라도 아래 기능 모두가 정상작동하지 않습니다.
case 2:
{
printf(이름, 연락처, 주소, 생일 순으로 입력\n);
scanf(%s %s %s %s,
book[count].name, book[count].cell, book[count].addr, book[count].addr);
count++;
printf(%s %s %s %s, book[count].name, book[count].cell, book[count].addr, book[count].addr);
break;
}
case 3:
{
//book[count].name = null;
count--;
break;
}
case 4:
{
printf(찾을 사람의 이름을 입력하세요 : \n);
scanf(%s, searchname);
searchlist(book, searchname, count);
break;
}
case 5:
{
printf(프로그램 종료);
break;
}
}
if(i == 5)break;
}
return 0;
}
//이부분은 이름에 따라 리스트를 검색하는 searchlist부분입니다. 질문과는 별 상관없습니다.
void searchlist(book book[], char *name, int count){
int i, x = 1;
for(i = 0; i count ; i++)
{
if(stsp;if(strcmp(book[i].name, name)){
printf(이름 전화번호 주소 생일\n);
printf(%s %s %s %s,
book[count].name, book[count].cell, book[count].addr, book[count].birth);
x = 0;
}
}
if(x != 0)
printf(찾는 정보가 없습니다\n);
}