diff options
| author | Tyge Løvset <[email protected]> | 2021-12-14 19:50:10 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2021-12-14 19:50:10 +0100 |
| commit | 6749cc21a2045d307c239d82891cb860687dfd2a (patch) | |
| tree | 6987b4cd03caa9b1ad8ab29bd97a7d8d15fcaa67 /examples/sview_split.c | |
| parent | c083936d8fa46b5df921dedae6ca15e1192d6612 (diff) | |
| download | STC-modified-6749cc21a2045d307c239d82891cb860687dfd2a.tar.gz STC-modified-6749cc21a2045d307c239d82891cb860687dfd2a.zip | |
Added and renamed some examples.
Diffstat (limited to 'examples/sview_split.c')
| -rw-r--r-- | examples/sview_split.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/examples/sview_split.c b/examples/sview_split.c new file mode 100644 index 00000000..3a079583 --- /dev/null +++ b/examples/sview_split.c @@ -0,0 +1,17 @@ +#include <stc/csview.h>
+#define c_arg(a) a
+int main()
+{
+ // No memory allocations or string length calculations!
+ const csview date = c_sv("2021/03/12");
+ const csview year = csview_first_token(date, c_sv("/"));
+ const csview month = csview_next_token(date, c_sv("/"), year);
+ const csview day = csview_next_token(date, c_sv("/"), month);
+
+ printf(c_svfmt ", " c_svfmt ", " c_svfmt "\n", c_svarg(year), c_svarg(month), c_svarg(day));
+
+ c_auto (cstr, y, m, d) {
+ y = cstr_from_v(year), m = cstr_from_v(month), d = cstr_from_v(day);
+ printf("%s, %s, %s\n", y.str, m.str, d.str);
+ }
+}
\ No newline at end of file |
