-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest1.c
More file actions
37 lines (32 loc) · 917 Bytes
/
test1.c
File metadata and controls
37 lines (32 loc) · 917 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
26
27
28
29
30
31
32
33
34
35
36
37
//
// Created by JakoError on 2021/10/15.
//
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include "ast.h"
#pragma warning(disable:4996)
String mystrcat(String *dst, String src) {
if (dst == NULL) return NULL;
if (src == NULL || strlen(src) == 0) return *dst;
int r;
if (*dst == NULL) {
*dst = malloc(sizeof(char) * (strlen(src) + 100));
r = 0;
} else {
*dst = realloc(*dst, sizeof(char) * (strlen(*dst) + strlen(src) + 100));
r = (int) strlen(*dst);
}
for (int i = 0; i < strlen(src); ++i)
(*dst)[r++] = src[i];
(*dst)[r] = '\0';
return *dst;
}
int main() {
String str = malloc(1000);
strcpy(str, "1122296vgp34uh8npppppppppppppppppqpppppppppppu-quvg9608tq37-v4908tj-q34vt33");
String *p = malloc(0);
printf("%d",strlen(" "));
return 0;
}