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

#include 
#include 
/*
	不用 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;
}

你可能感兴趣的:(c语言,基础)