문자열 합치기(strcat_s) C언어

홍성우·2023년 4월 19일

자료구조 (C언어)

목록 보기
2/15
char* mystrcat(char* pszBuffer, char* param) {

	while (*pszBuffer != '\0') {
		pszBuffer = pszBuffer + 1;

	}
	while (*param != '\0')
		*pszBuffer++ = *param++;
	
	*pszBuffer = '\0';

	return pszBuffer--;

}

int main() {

	// 문자열 붙이기
	char szpath[128] = { 0 };
	char* pszEnd = NULL;

	pszEnd = mystrcat(szpath, "c:\\programming Files\\");
	pszEnd = mystrcat(szpath, "CHS\\");
	pszEnd = mystrcat(szpath, "C Programming");

	puts(szpath);
	
	return 0;
}

profile
제 블로그를 방문해 주셔서 감사합니다

0개의 댓글