[此贴子已经被作者于2007-6-21 9:38:06编辑过]
[此贴子已经被作者于2007-6-21 9:38:06编辑过]
汗 4 5 6 8楼都是正解
你还问
你是不是就是等着 卧龙孔明 来啊
如果你真是等他那你最好先去看一下他的签名
我看他应该学的好才说的,他不给别人说题吗?
我看他应该学的好才说的,他不给别人说题吗?
他最近要会考 没时间来论坛 你这个帖子得顶几个礼拜才能看到他回
3.
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
char *s1 = "abcdef", *s2 = "123456",*s3;
s3 =(char *) malloc(sizeof(char)*100);
strcpy(s1, s3);
strcat(s3, s2);
printf("\n%s\n",s3);
return 0;
}
最后应该能打印出你要求的s3.
malloc是动态分配内存
这么用纯属多余 而且用的也不对
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
int main(void)
{
char *s1 = "abcdef", *s2 = "123456", *s3;
s3 =(char *) malloc(sizeof(char)*(strlen(s1)+strlen(s2)));
strcpy(s3, s1);
strcat(s3, s2);
printf("%s\n", s3);
free(s3);
return 0;
}
楼主太.......懒了......