编写一个程序,将两个字符串连接起来,不要使用strcat函数 C语言

2016-06-17 16:20:39  分类: c程序设计第四版谭浩强课后答案  参与:

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

【c源程序】
#include <stdio.h>
int main()
{ char s1[80],s2[40];
  int i=0,j=0;
  printf("input string1:");
  scanf("%s",s1);
  printf("input string2:");
  scanf("%s",s2);
  while (s1[i]!='\0')
    i++;
  while(s2[j]!='\0')
    s1[i++]=s2[j++];
  s1[i]='\0';
  printf("\nThe new string is:%s\n",s1);
  return 0;
 }


来源:c程序设计第四版谭浩强课后答案

本文链接:http://www.wb98.com/c/post/tanhaoqiang_6.13.html

本站文章搜索:

<< 上一篇下一篇 >>

搜索

网站分类

Tags列表

赞助商链接