diff options
Diffstat (limited to 'docs/cstr_api.md')
| -rw-r--r-- | docs/cstr_api.md | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/docs/cstr_api.md b/docs/cstr_api.md index 0f9589d9..3857633a 100644 --- a/docs/cstr_api.md +++ b/docs/cstr_api.md @@ -160,30 +160,30 @@ char* cstrnstrn(const char* str, const char* search, size_t slen, size_t #include <stc/cstr.h> int main() { - cstr s0 = cstr_lit("Initialization without using strlen()."); - printf("%s\nLength: %" c_ZU "\n\n", cstr_str(&s0), cstr_size(&s0)); + c_AUTO (cstr, s0, s1, full_path) { + s0 = cstr_lit("Initialization without using strlen()."); + printf("%s\nLength: %" c_ZU "\n\n", cstr_str(&s0), cstr_size(&s0)); - cstr s1 = cstr_lit("one-nine-three-seven-five."); - printf("%s\n", cstr_str(&s1)); + s1 = cstr_lit("one-nine-three-seven-five."); + printf("%s\n", cstr_str(&s1)); - cstr_insert(&s1, 3, "-two"); - printf("%s\n", cstr_str(&s1)); + cstr_insert(&s1, 3, "-two"); + printf("%s\n", cstr_str(&s1)); - cstr_erase(&s1, 7, 5); // -nine - printf("%s\n", cstr_str(&s1)); + cstr_erase(&s1, 7, 5); // -nine + printf("%s\n", cstr_str(&s1)); - cstr_replace(&s1, "seven", "four", 1); - printf("%s\n", cstr_str(&s1)); + cstr_replace(&s1, "seven", "four", 1); + printf("%s\n", cstr_str(&s1)); - // reassign: - cstr_assign(&s1, "one two three four five six seven"); - cstr_append(&s1, " eight"); - printf("append: %s\n", cstr_str(&s1)); + // reassign: + cstr_assign(&s1, "one two three four five six seven"); + cstr_append(&s1, " eight"); + printf("append: %s\n", cstr_str(&s1)); - cstr full_path = cstr_from_fmt("%s/%s.%s", "directory", "filename", "ext"); - printf("%s\n", cstr_str(&full_path)); - - c_drop(cstr, &s0, &s1, &full_path); + full_path = cstr_from_fmt("%s/%s.%s", "directory", "filename", "ext"); + printf("%s\n", cstr_str(&full_path)); + } } ``` Output: |
