sc/string/str_example.c

28 lines
469 B
C
Raw Normal View History

2020-11-11 01:19:49 +03:00
#include "sc_str.h"
#include <stdio.h>
2021-02-07 22:31:04 +03:00
int main()
2020-11-11 01:19:49 +03:00
{
char *s1;
2020-11-11 01:19:49 +03:00
s1 = sc_str_create("*-hello-*");
printf("%s \n", s1); // prints **hello**
2020-11-11 01:19:49 +03:00
sc_str_trim(&s1, "*-");
printf("%s \n", s1); // prints hello
2021-02-04 11:17:43 +03:00
sc_str_append_fmt(&s1, "%d", 2);
printf("%s \n", s1); // prints hello2
2021-02-04 11:17:43 +03:00
sc_str_replace(&s1, "2", " world!");
printf("%s \n", s1); // prints hello world!
2020-11-11 01:19:49 +03:00
sc_str_substring(&s1, 0, 5);
printf("%s \n", s1); // prints hello
2020-11-11 01:19:49 +03:00
sc_str_destroy(s1);
2020-11-11 01:19:49 +03:00
return 0;
2020-11-11 01:19:49 +03:00
}