编一程序,将两个字符串连接起来,不要用strcat函数.

版权声明:Sock的blog, 可以偷看但不可以偷走哦 https://blog.csdn.net/qq_42957923/article/details/84846734
#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++;
	}
}

int main() {
	char string1[1024] = "I love ";
	char string2[1024] = "you";
	Strcat(string1, string2);
	printf("%s\n", string1);

	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_42957923/article/details/84846734