实验报告->数组的定义和使用->连接两个字符串

来源:互联网 发布:少儿编程软件 编辑:程序博客网 时间:2024/05/18 23:56

/*
程序填空,将两个字符串连接起来,不要使用strcat函数。
*/

#define N 40#include <stdio.h>void main(){    int i=0, j=0;    char s[N];    char t[2*N];    scanf("%s", &s);    scanf("%s", &t);    printf("s中的字符串为:%s\n", s);    printf("t中的字符串为:%s\n", t);    while(s[i]!='\0')   i++;    while(t[j]!='\0')  s[i++] = t[j++];    s[i]='\0';    printf("s、t连接后的字符串为:%s", s);}
阅读全文
0 0
原创粉丝点击