• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

cxr119911

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

No.7 连接数组

 "stdio.h"
#include "string.h"
#define ARR_SIZE 80
void lianjie(char str1[],char str2[]);
int main()
{char s[ARR_SIZE],t[ARR_SIZE];
printf("Input s:\n");
gets(s);
printf("Input t:\n");
gets(t);
lianjie(s,t);
printf("Result is:\n");
 puts(s);
}
void lianjie(char str1[],char str2[])
{int i=0,j;
while(str1[i]!='\0'){i++;}
 for(j=0;str2[j]!='\0';j++,i++)
 {str1[i]=str2[j];}
 str1[i]='\0';
}
 
一、调用的函数表达的功能,而主函数则输出结果;
二、getchar()的含义:等待输入数据(回车);
三、i和j一定要注意。不要写错。
 

posted on 2016-12-02 16:51  cxr119911  阅读(82)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3