-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstr.cpp
More file actions
25 lines (25 loc) · 842 Bytes
/
Copy pathstr.cpp
File metadata and controls
25 lines (25 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "../include/str.h"
void strval(char **str1,const char *str2,int type){
switch (type)
{
case 1 : {
*str1=(char *)malloc(strlen(str2+1));
sprintf(*str1,"%s",str2);
printf("case 1 :%s\n",*str1);
break;
}
case 2 : {
*str1 = (char *)realloc(*str1,strlen(*str1)+strlen(str2)+1);
sprintf(*str1,"%s%s",*str1,str2);
printf("case 2 :%s\n",*str1);
}
break;
case 3 : {
free(*str1);
*str1=(char *)malloc(strlen(str2+1));
sprintf(*str1,"%s",str2);
printf("case 3 :%s\n",*str1);
break;
}
}
}