포인터 변수로 단어 입력받아서 알파벳 순서대로 출력하기
맞손질
질문 제목 : 포인터 변수로 단어 입력받아서 알파벳 순서대로 출력하기질문 요약 :포인터 변수로 단어 입력받아서 알파벳 순서대로 출력하기질문 내용 :
#includestdio.h
#includestring.h
void exchange(char *, char *);
void line_up(char **);
void main()
{
char word[10][20];
char *str[10];
int i;
printf(정렬할 영단어 10개를 입력하세요. (길이20이하)\n);
for(i=0; i10; i++)
{
scanf(%s, word[i]);
str[i] = word[i];
}
printf(\n정렬된 결과\n);
line_up(str);
for(i=0; i10; i++)
{
printf(%s\n, str[i]);
}
}
void line_up(char **cp)
{
int i;
for(i=0; i9; i++)
{
for(j=1; j10; j++)
{
if(strcmp(cp[i],cp[j])0) exchange(cp[i], cp[j]);
}
}
}
void exchange(char *ap, char *bp)
{
char temp[20];
strcpy(temp,ap);
strcpy(ap,bp);
strcpy(bp,temp);
}
하.. 빨간 부분이 문제인 것 같은데....
오류랑 경고는 없는데요.....
출력도 잘 되는데..
알파벳 순으로 안됩니다..ㅠㅠㅠㅠㅠ
왜그럴까요..ㅜㅜ 몇시간째인지... 도와주세요ㅠㅠ