正在加载图片...
第7章第3节 七、字符数组应用举例 P1427.13编写一个程序,将两个字符串连接起来,不用 Streat函数。 解 ABICIDI1O # include” stdio.hs FGHI\O maint fint i, k; char sl201, s2 101; printf((“ input strings:Ⅶn”); gets(s1); printf(“ input stringS2:in”) gets(s2); for(i=0; sll!=10; i++); kEi: for(i=0;s2[i!=“03,;i+) slk+i=s2i; 为什么这样做 1k+i=“0 puts(s1);七. 字符数组应用举例 P142 7.13 编写一个程序, 将两个字符串连接起来,不用strcat函数。 第7章第3节 A B C D \0 E F G H \0 # include ”stdio.h” main() {int i,k; char s1[20],s2[10]; printf(“input string s1: \n”); gets(s1); printf(“input string s2: \n”); gets(s2); for (i=0; s1[i]!=‘\0’;i++) ; k=i; for (i=0; s2[i]!=‘\0’;i++) s1[k+i]=s2[i]; s1[k+i]=‘\0’; puts(s1); } s1 s2 为什么这样做? 解:
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有