Robot
Move a little robot.
string.h
Go to the documentation of this file.
1#include <stddef.h>
2#include <stdarg.h>
3
15struct string {
16 char* start;
18 size_t used_size;
19};
20
29void string_init(struct string* s);
30
36void string_deinit(struct string* s);
37
46void string_clear(struct string* s);
47
55size_t string_len(struct string* s);
56
65void string_print(struct string* s);
66
76void string_append_with_size(struct string* s, const char* following, size_t len_following);
77
86void string_append(struct string* s, const char* following);
87
102int string_snprintf(struct string* s, const char* format, ...);
103
112#define string_append_literal(x, y) string_append_with_size(x, y, (sizeof y) - 1)
void string_clear(struct string *s)
Clears the contents of the string, making it empty.
void string_append_with_size(struct string *s, const char *following, size_t len_following)
Append a const char* to the string's content (size of following given).
void string_print(struct string *s)
Prints the string's content and internal data (pointers and sizes).
void string_append(struct string *s, const char *following)
Append a const char* to the string's content.
size_t string_len(struct string *s)
Returns the length of the string (excluding the final '\0').
int string_snprintf(struct string *s, const char *format,...)
Formats a string and stores the result in a dynamically allocated string struct.
void string_init(struct string *s)
Initializes a string structure with an empty string.
void string_deinit(struct string *s)
Frees (de-initializes) memory used by a string structure.
A dynamically allocated string structure.
Definition: string.h:15
size_t available_size
Definition: string.h:17
size_t used_size
Definition: string.h:18
char * start
Definition: string.h:16