1#define NONSTD_IMPLEMENTATION
 2#include "../nonstd.h"
 3
 4#include <stdio.h>
 5
 6int main(void) {
 7	// 1. Basic usage
 8	const char *msg = "Hello, World!\n";
 9	if (write_entire_file("test_basic.txt", msg, strlen(msg))) {
10		printf("Written test_basic.txt\n");
11	}
12
13	size_t sz;
14	char *content = read_entire_file("test_basic.txt", &sz);
15	if (content) {
16		printf("Read: %.*s", (int)sz, content);
17		FREE(content);
18	}
19
20	// 2. usage with string view
21	stringv sv = sv_from_cstr("Hello from String View!\n");
22	if (write_file_sv("test_sv.txt", sv)) {
23		printf("Written test_sv.txt\n");
24	}
25
26	// 3. usage with string builder
27	stringb sb;
28	sb_init(&sb, 0);
29	sb_append_cstr(&sb, "Hello from ");
30	sb_append_cstr(&sb, "String Builder!\n");
31
32	if (write_file_sb("test_sb.txt", &sb)) {
33		printf("Written test_sb.txt\n");
34	}
35
36	// Read into stringb
37	stringb sb2 = read_entire_file_sb("test_sb.txt");
38	if (sb2.data) {
39		printf("Read into sb: %s", sb2.data);
40		sb_free(&sb2);
41	}
42
43	sb_free(&sb);
44
45	return 0;
46}