早教吧 育儿知识 作业答案 考试题库 百科 知识分享

急编写C函数就是C函数库里函数的功能.编写C函数:1)字符串连接函数StrCat(char*firstStr,char*secondStr),把secondStr所指的字符串添加到firstStr所指的字符串的末尾;2)字符串复制函数StrCpy(c

题目详情
【急】编写C函数 就是C函数库里函数的功能.
编写C函数:
1)字符串连接函数StrCat (char *firstStr,char *secondStr),把secondStr所指的字符串添加到firstStr所指的字符串的末尾;
2)字符串复制函数StrCpy (char *firstStr,char *secondStr),把secondStr所指的字符串复制到firstStr所指的字符串中.
▼优质解答
答案和解析
char* StrCat (char *firstStr, char *secondStr)
{
char* beg = firstStr;
while(*firstStr) ++firstStr;
while(*firstStr++=*secondStr++);
return beg;
}
char* StrCpy (char *firstStr, char *secondStr)
{
char* beg = firstStr;
while(*firstStr++=*secondStr++);
return beg;
}