blob: 826a581141de15108522b73fbcd6d71aa2225f4b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include <stdio.h>
void z_strcat(char* s, char* t) {
// Skip to the end of s
for (; *s != '\0'; s++) {}
// Copy over t
for (; *t != '\0'; t++, s++) {
*s = *t;
}
// Ensure null terminator
*s = '\0';
}
int main(void) {
char buf[100] = "";
z_strcat(buf, "foo");
printf("%s\n", buf);
z_strcat(buf, "bar");
printf("%s\n", buf);
}
|