#include
#include
void Compare(char* na);
char name[20];
char number[20];
char hong[] = "홍길동";
char *hong1num = { "010-5210-1234" };
char *hong2num = { "010-8255-8255" };
float score1 = 4.2;
float score2 = 3.8;
int main() {
Compare(name);
return 0;
}
void Compare(char* na)
{
while (strcmp(na, hong))//있는 이름이면 종료, 없는 이름이면 반복
{
printf("정보를 찾고 싶은 학생 이름은? ");
gets(name);
if (!strcmp(na, hong)) {
printf("===================================\n");
printf("이름 전화번호 평점\n");
printf("%s %s %f\n", hong, hong1num, score1);
printf("%s %s %f\n", hong, hong2num, score2);
printf("===================================\n");
printf("같습니다! \n"); //이부분
}
else {
printf("===================================\n");
printf("이름 전화번호 평점\n");
printf("===================================\n");
printf("===================================\n");
printf("%s(이)라는 학생은 없습니다 \n", na);
}
}
return 0;
}
배우는중이라 코드 ㅈ같은건 압니다.
같은이름 '홍길동'을 검색시 printf("같습니다! \n"); 이 부분을
저장된 홍길동이란 이름을 총 몇개인지 세서 printf("x 명입니다 \n"); 이렇게 만들고싶습니다.
어떤걸 어떻게 쓰면 될까요
성님들 부탁합니다
카운트 변수 하나 만들고 찾을때마다 ++ - dc App
아니 하나밖에없는데 뭘 중복아야색기야