Updated slice examples to show string is not required to be mutable

This commit is contained in:
cannoli-fruit 2026-07-09 01:18:55 -04:00
commit 52d7e8a1c2
2 changed files with 2 additions and 8 deletions

View file

@ -1,13 +1,12 @@
#define LAZY_IMPL
#include "../lazy.h"
#include <string.h>
#include <stdio.h>
#include <ctype.h>
int isnotalpha(int x) { return !isalpha(x); }
int main() {
char *src = lz_cstr_dup("This is a list of words, which apparently has been referred to previously as a sentence");
char *src = "This is a list of words, which apparently has been referred to previously as a sentence";
Lz_Slc s = lz_cstr_to_slc(src);
Lz_Slc word;
@ -18,8 +17,5 @@ int main() {
++i;
} while(s.cnt != 0);
free(src);
return 0;
}

View file

@ -1,18 +1,16 @@
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#define LAZY_IMPL
#include "../lazy.h"
int main() {
char *src = lz_cstr_dup(" \t This text has some extra whitespace \t ");
char *src = " \t This text has some extra whitespace \t ";
Lz_Slc s = lz_cstr_to_slc(src);
printf("|"LZ_STR_FMT"|\n", LZ_STR_PRINTF(s));
lz_trim_typ(&s, isspace);
printf("|"LZ_STR_FMT"|\n", LZ_STR_PRINTF(s));
free(src); // excessive but this is how you should do it
return 0;
}