I came into mystrcat and copied the address, but the contents don't seem to be copied
#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;
}
while (*pszDst != '\0');
++pszDst;
Delete the semicolon (;
) at the end of the while line.
while (*pszDst != '\0')
++pszDst;
© 2024 OneMinuteCode. All rights reserved.