영어 단어를 입력해서
입력한 순서하고 오른차순으로 정렬된 순서로
동시에 출력시키는 프로그램을 만드는데....
숫자변수로는 잘 되는것이 문자열로 하니까 잘 안돼....
자꾸 strcpy하고 ctrcmd에서 애러가나... 주위에 물어볼 사람도 없고
정말 답답해서 횽들한테 물어보는거야...
그나저나 포인터 제대로 못쓰면 실무가서 막장이야?
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MAX 10
typedef char strr[MAX];
void main()
{
strr word[MAX], *pWord[MAX], *temp;
int i, j;
int num;
for(i=0; i<MAX; i++)
{
printf(\"%d번째 단어 : \", i+1);
gets(word[i]);
}
for(i=0; i<MAX; i++)
{
/* 이 부분에서 계속 애러가나
strcpy(pWord[i], word[i]);
}
for(i=0; i<MAX-1; i++)
{
for(j=i+1; j<MAX; j++)
{
num = strcmp(*pWord[i], *pWord[j]);
if(num == 1)
{
strcpy(*temp, *pWord[i]);
strcpy(*pWord[i], *pWord[j]);
strcpy(*pWord[j], *temp);
}
}
}
printf(\"원본\\t\\t포인터\\n\");
for(i=0; i<MAX; i++)
{
printf(\"%s\\t\\t%s\\n\", word[i], *pWord[i]);
}
}
pWord동적할당 필.. 이룬 헉..