#include <stdio.h>
#include <windows.h>
/*
不用 strcat 将两个字符串连接起来
*/
//写一个这样的函数
void Strcat(char* current, const char* extra) {
//while (*current++ != '\0');
//--current;
while (*current != '\0') {
++current;
}
while (*extra != '\0') {
*current++ = *extra++;
}
*current = *extra;
}
int main() {
char string1[1024] = "I love ";
char string2[1024] = "you";
Strcat(string1, string2);
printf("%s\n", string1);
system("pause");
return 0;
}
编一程序,将两个字符串连接起来,不要用strcat函数.
最新推荐文章于 2024-07-11 11:00:00 发布