1. 程式人生 > >strcat函式C實現

strcat函式C實現

#include "stdio.h"

char *strcat(char *str1, char *str2)
{
	if((str1==NULL)||(str2==NULL)) throw "Invalide arguments!";
	char *pt = str1;
	while(*str1!='\0') str1++;
	while(*str2!='\0') *str1++ = *str2++;
	*str1 = '\0';
	return pt;
}

void main()
{
	char a[]= "markyuan";
	char b[]= "yyyyy";
	char *cat = strcat(a,b);
	printf("%s\n",cat);
}