diff options
| author | Tyge Løvset <[email protected]> | 2021-05-25 10:53:57 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-05-25 10:53:57 +0200 |
| commit | eb4450324de7211fbd8c80a2c566f3a1bfddd3c7 (patch) | |
| tree | 12e66d1c6d927df5903afb4fc27931b3b862d335 /examples/splitstr.c | |
| parent | 41ef6709c8371b6240b24b8258c12ba61c52cdcb (diff) | |
| download | STC-modified-eb4450324de7211fbd8c80a2c566f3a1bfddd3c7.tar.gz STC-modified-eb4450324de7211fbd8c80a2c566f3a1bfddd3c7.zip | |
Small refactoring and improved docs.
Diffstat (limited to 'examples/splitstr.c')
| -rw-r--r-- | examples/splitstr.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/splitstr.c b/examples/splitstr.c index 67499d0f..ba49ddcf 100644 --- a/examples/splitstr.c +++ b/examples/splitstr.c @@ -33,7 +33,10 @@ int main() print_split(c_lit("This has no matching separator"), c_lit("xx")); puts("");
puts("Output from string_split():");
- c_forvar (cvec_str v = string_split(c_lit("Split,this,,string,now,"), c_lit(",")), cvec_str_del(&v))
- c_foreach (i, cvec_str, v)
+ cstr string = cstr_lit("Split,this,,string,now,");
+ cvec_str vec = string_split(c_sv(string), c_lit(","));
+
+ c_fordefer (cvec_str_del(&vec), cstr_del(&string))
+ c_foreach (i, cvec_str, vec)
printf("\t\"%s\"\n", i.ref->str);
}
\ No newline at end of file |
