#include <stdio.h>int main(){ char s1[80],s2[40]; int i=0,j=0; printf("Please input y ...
.用字符数组和自己书写的函数实现 自己写一个具有strcat函数功能的函数 实现代码如下: include lt iostream gt using namespace std int main char a ,b void Strcat char a ,char b cout lt lt please input first string: lt lt endl cin gt gt a cou ...
2013-07-20 23:09 0 10163 推荐指数:
#include <stdio.h>int main(){ char s1[80],s2[40]; int i=0,j=0; printf("Please input y ...
编一程序,将两个字符串连接起来,不要用strcat函数 【答案解析】 直接将s2中的字符逐个拷贝到s1的末尾即可,用户需要保证s1中能存的下s2中的字符 获取s1末尾的位置 将s2中的字符逐个拷贝到s1中 【代码实现】 【结果截屏】 ...
编一程序,将两个字符串连接起来,不要用strcat函数 【答案解析】 直接将s2中的字符逐个拷贝到s1的末尾即可,用户需要保证s1中能存的下s2中的字符 获取s1末尾的位置 将s2中的字符逐个拷贝到s1中 【代码实现】 【结果截屏】 ...
...
字符串的连接如图所示: 如果字符串 1 中有 n 个元素,那么就是把字符串 2 中的第 i 个元素赋值给字符串 1 中的第 i + n 个元素。 n 可以通过对字符串 1 的循环直到 '\0' 找到。 话不多说,代码如下。 是不是很简单呢?欢迎小伙伴们留言 ...
源程序: 第一种方法: #include <iostream> #include <string> using namespace std; int main() { string str1="i am "; string str2 ...
!= '\0') { str1++; //让指针指向字符串的尾部 } while (*str2 != '\0') { *st ...