mystrcat
#include<stdio.h>
//如果一個數(shù)組做為函數(shù)的形參傳遞,那么數(shù)組可以在被調(diào)用的函數(shù)中修改
//有時候不希望這個事發(fā)生,所以對形參采用const參數(shù)
//size_t strlen(const char *s);
//strcpy(char* s1,const char* s2);
void mystrcat(char *s1,const char *s2)
{int len = 0;while(s2[len]){len++;}while(*s1){s1++;}int i;for(i = 0; i < len; i++){*s1 = *s2;s1++;s2++;}
}int main()
{char s1[10] = "123";char s2[10] = "456";mystrcat(s1,s2);printf("s1 = %s\n",s1);return 0;
}
?
轉載于:https://www.cnblogs.com/wanghao-boke/p/11006984.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎總結