题目
解决代码及点评
/*
编写一个函数JOIN,让它实现字符串连接运算功能。
*/
#include <stdio.h>
#include <stdlib.h> void JOIN(char *p1,char *p2,int n,int count1,int count2)//字符串链接函数
{
if (n<count1+count2+1)
{
printf("第一个字符串长度不够");
}
else
{
count2=0;
while(p1[count1++]=p2[count2++]); }
}
void main()
{
char str1[50]="abcdefghijk";
char str2[]="1234567890"; int count1=0;//记录第一个字符串长度
int count2=0;//记录第二个字符串长度 while(str1[count1]) count1++;
while(str2[count2]) count2++; int n=sizeof(str1);//计算数组一的字节数 JOIN(str1,str2,n,count1,count2); printf("%s",str1); system("pause");
}
代码编译以及运行
由于资源上传太多,资源频道经常被锁定无法上传资源,同学们可以打开VS2013自己创建工程,步骤如下:
1)新建工程
2)选择工程
3)创建完工程如下图:
4)增加文件,右键点击项目
5)在弹出菜单里做以下选择
6)添加文件
7)拷贝代码与运行
程序运行结果
代码下载
http://download.****.net/detail/yincheng01/6681845
解压密码:c.itcast.cn