char* strcpy(char* strDest, const char* strSrc) // 對於並不改變的參數,使用const限定
{
assert((strDest != NULL) && (strSrc != NULL)); // 首先判斷合法性
char* address = strDest;
while((*strDest++ = *strSrc++) != '\0');
return address; // 方便鏈式操作,需要返回目標字符串的指針
}
int strlen(const char* strSrc)
{
assert(strSrc != NULL);
int count = 0;
while(*strSrc++ != '\0')
{
count++;
}
return count;
}
c語言總結:strcpy和strlen
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章
24小時熱門文章