-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_buf.c
More file actions
31 lines (25 loc) · 752 Bytes
/
Copy pathtest_buf.c
File metadata and controls
31 lines (25 loc) · 752 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
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "buf.h"
int main()
{
buf_t *buf;
buf = buf_new(0);
char *s = "buffers, aheeey";
buf_sprintf(buf, "%s", s);
printf("len: %lu, size: %lu, strlen: %lu, [%s]\n",
buf->len, buf->size, strlen(buf->data), buf->data);
char *abcd = "abcd";
buf_sprintf(buf, "%s", abcd);
printf("len: %lu, size: %lu, strlen: %lu, [%s]\n",
buf->len, buf->size, strlen(buf->data), buf->data);
return 0;
int a = 20;
buf_append(buf, "a little project. ", 18);
buf_sprintf(buf, "testing %s this %d\n", s, a);
printf("len: %lu, size: %lu\n", buf->len, buf->size);
buf_expand(buf, 4096);
printf("len: %lu, size: %lu, s: %s\n", buf->len, buf->size, buf->data);
printf("%s\n", buf->data);
}