From 39148b1b6dc6c7a10f7e713ece084b6d5cf27537 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 16 Feb 2025 20:03:40 +0100 Subject: Initial --- string.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 string.h (limited to 'string.h') diff --git a/string.h b/string.h new file mode 100644 index 0000000..ecb49b6 --- /dev/null +++ b/string.h @@ -0,0 +1,19 @@ +#pragma once + + +struct string { + size_t len, cap; + char *data; // null-terminated +}; + +struct string string_make(const char *str); + +void string_free(struct string s); + +// Do not modify the length of the string. +char* string_read(struct string s); + +// Returns original length. +size_t string_append(struct string *s, char *arg); + +void string_truncate(struct string *s, size_t length); -- cgit v1.2.3-70-g09d2