mirror of
https://git.wolves.top/wolves/leetcode.git
synced 2025-11-04 17:26:32 +08:00
init
This commit is contained in:
18
we/24-sy-3.c
Normal file
18
we/24-sy-3.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char *strcpys(char *dest,char *src){
|
||||
int len1 = strlen(dest);
|
||||
int len2 = strlen(src);
|
||||
char *res = (char *)malloc(sizeof(char)*(len1+len2+1));
|
||||
if(!res){
|
||||
printf("malloc failed\n");
|
||||
return NULL;
|
||||
}
|
||||
memcpy(res,dest,len1);
|
||||
memcpy(res+len1,src,len2);
|
||||
res[len1+len2] = '\0';
|
||||
|
||||
free(src);
|
||||
return res;
|
||||
}
|
||||
Reference in New Issue
Block a user