[[프로그래밍_NOTE]]/C , C++

strcat 기능 구현

갑빠돌격기 2008. 8. 13. 14:23

/** strcat()의 함수 사용 ********************************
#include<stdio.h>
#include<string.h>

void main()
{
   char temp1[16] = {"홍길동"};
 const char temp2[8]  = {"김길동"};

 strcat(temp1 , temp2);
 printf("temp1->%s\n",temp1);
}
******************************************************/

/** 동일한 기능의 MyStrCat() 함수 구현 ******************
#include<stdio.h>

void MyStrCat(char* pDestptr , const char* pSourceptr)
{
 for( ; *pDestptr ;  ++pDestptr);
 while(*pDestptr++ = *pSourceptr++);
}

void main()
{
   char temp1[16] = {"홍길동"};
 const char temp2[8]  = {"김길동"};
   
 MyStrCat(temp1 , temp2);
 printf("temp1->%s\n",temp1);
}
******************************************************/
result )

사용자 삽입 이미지