1个回答
展开全部
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void main()
{
char *src = "srcStr";
char *dest = "dstS";
int len1 = strlen(src), len2 = strlen(dest);
char *str = (char *)malloc(len1 + len2 +1);
if (str == NULL)
{
printf("Allocate Memory Error!\n");
return;
}
strcpy(str,dest);
strcpy(&str[len2],src);
str[len1+len2] = '\0';
printf("%s",str);
}
#include <stdlib.h>
#include <string.h>
void main()
{
char *src = "srcStr";
char *dest = "dstS";
int len1 = strlen(src), len2 = strlen(dest);
char *str = (char *)malloc(len1 + len2 +1);
if (str == NULL)
{
printf("Allocate Memory Error!\n");
return;
}
strcpy(str,dest);
strcpy(&str[len2],src);
str[len1+len2] = '\0';
printf("%s",str);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询