strcat함수를 만들어 보았는데 실행이 되질 않아 질문합니다.
조회수 403회
mystrcat에 들어와서 주소는 복사해서 가는데 내용물은 복사를 안하는 듯합니다
#include <stdio.h>
#include <string.h>
char* mystrcat(char* pszDst, char* pszSrc)
{
while (*pszDst != '\0');
++pszDst;
while (*pszSrc != '\0')
*pszDst++ = *pszSrc++;
*++pszDst = '\0';
return --pszDst;
}
int main() {
char szPath[128] = { 0 };
char* pszEnd = NULL;
pszEnd = mystrcat(szPath, "C:\\Program Files\\");
pszEnd = mystrcat(pszEnd, "CHS:\\");
pszEnd = mystrcat(pszEnd, "C programming");
puts(szPath);
return 0;
}
-
(•́ ✖ •̀)
알 수 없는 사용자 - 〉
1 답변
-
while (*pszDst != '\0'); ++pszDst;
while 라인 마지막의 세미콜론(
;
)을 삭제하세요.while (*pszDst != '\0') ++pszDst;
댓글 입력