매개변수로 포인터 넘겨주는 거 왜이리 어렵냐
ㅈㄴ어렵눙;;
#include<stdio.h>
#include<string.h>
void SortString(char** str, int strCount)
{
const int nSize = 12;
char sMin[nSize] = { 0 };
int i = 0, j = 0;
for (i = 0; i < strCount - 1; ++i)
{
for (j = i + 1; j < strCount; ++j)
{
if (strncmp(*(str + i), *(str + j), nSize) == 1)
{
memcpy(sMin, *(str + j), nSize);
memcpy(*(str + j), *(str + i), nSize);
memcpy(*(str + i), sMin, nSize);
}
}
}
return;
}
int main(void)
{
const int nCount = 3;
const int nSize = 12;
char aList[nCount][nSize] = {
"랄로",
"파카",
"도파"
};
char* paList[nCount]{
aList[0],
aList[1],
aList[2]
};
int i = 0;
for (i = 0; i < nCount; ++i)
{
puts(*(paList + i));
}
SortString(paList, nCount);
puts("SortString");
puts("");
for (i = 0; i < nCount; ++i)
{
puts(*(paList + i));
}
return 0;
}
댓글 0