summaryrefslogtreecommitdiffhomepage
path: root/examples/replace.c
diff options
context:
space:
mode:
authorTyge Lovset <[email protected]>2022-12-20 23:31:51 +0100
committerTyge Lovset <[email protected]>2022-12-20 23:31:51 +0100
commit5f57d597cd27aef55adbcb3b452973b0c6e33667 (patch)
treedfd59c2fd0e36a6ef37912a9d0cc5a65970f1524 /examples/replace.c
parent1763be8c8cbbc0896477fcf924edd4180d1345a9 (diff)
downloadSTC-modified-5f57d597cd27aef55adbcb3b452973b0c6e33667.tar.gz
STC-modified-5f57d597cd27aef55adbcb3b452973b0c6e33667.zip
Restructured folders: examples, benchmarks, tests into misc folder.
Diffstat (limited to 'examples/replace.c')
-rw-r--r--examples/replace.c34
1 files changed, 0 insertions, 34 deletions
diff --git a/examples/replace.c b/examples/replace.c
deleted file mode 100644
index 15cf3bae..00000000
--- a/examples/replace.c
+++ /dev/null
@@ -1,34 +0,0 @@
-#include <stc/cstr.h>
-
-int main ()
-{
- const char *base = "this is a test string.";
- const char *s2 = "n example";
- const char *s3 = "sample phrase";
-
- // replace signatures used in the same order as described above:
-
- // Ustring positions: 0123456789*123456789*12345
- cstr s = cstr_from(base); // "this is a test string."
- cstr m = cstr_clone(s);
- c_defer (cstr_drop(&s), cstr_drop(&m)) {
- cstr_append(&m, cstr_str(&m));
- cstr_append(&m, cstr_str(&m));
- printf("%s\n", cstr_str(&m));
-
- cstr_replace_at(&s, 9, 5, s2); // "this is an example string." (1)
- printf("(1) %s\n", cstr_str(&s));
-
- cstr_replace_at_sv(&s, 19, 6, c_SV(s3+7, 6)); // "this is an example phrase." (2)
- printf("(2) %s\n", cstr_str(&s));
-
- cstr_replace_at(&s, 8, 10, "just a"); // "this is just a phrase." (3)
- printf("(3) %s\n", cstr_str(&s));
-
- cstr_replace_at_sv(&s, 8, 6, c_SV("a shorty", 7)); // "this is a short phrase." (4)
- printf("(4) %s\n", cstr_str(&s));
-
- cstr_replace_at(&s, 22, 1, "!!!"); // "this is a short phrase!!!" (5)
- printf("(5) %s\n", cstr_str(&s));
- }
-}