用指针方法实现:输入两个字符串分别存入字符数组中,再将第二个字符串连接到第一个字符串之后并输出(不能调用strcat()函数)。
1条回答 默认 最新
- threenewbee 2019-11-28 09:44关注
#include <stdio.h> void mystrcat(char * s1, char * s2) { while (*s1) s1++; while (*s2) { *s1 = *s2; s1++;s2++; } *s1='\0'; } int main() { char s1[100]; char s2[100]; scanf("%s", s1); scanf("%s", s2); mystrcat(s1, s2); printf("%s", s1); return 0; }
问题解决请点采纳。
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 9无用 1