@@ -8,9 +8,11 @@ it will be used to create one.
88## Table of Contents <!-- omit in toc -->
99
1010- [ Q1: "How do I build cstring?"] ( #q1-how-do-i-build-cstring )
11- - [ Q2: "Does cstring have its own unit-tests?"] ( #q2-does-cstring-have-its-own-unit-tests )
12- - [ Q3: "How do I build without the C++ examples and tests?"] ( #q3-how-do-i-build-without-the-c-examples-and-tests )
13- - [ Q4: "Where are the examples?"] ( #q4-where-are-the-examples )
11+ - [ Q2: "How do I install cstring?"] ( #q2-how-do-i-install-cstring )
12+ - [ Q3: "How do I use cstring?"] ( #q3-how-do-i-use-cstring )
13+ - [ Q4: "Does cstring have its own unit-tests?"] ( #q4-does-cstring-have-its-own-unit-tests )
14+ - [ Q5: "How do I build without the C++ examples and tests?"] ( #q5-how-do-i-build-without-the-c-examples-and-tests )
15+ - [ Q6: "Where are the examples?"] ( #q6-where-are-the-examples )
1416
1517
1618# FAQs: <!-- omit in toc -->
@@ -37,7 +39,48 @@ $ ./prepare_cmake.sh -m
3739Execute ` $ ./prepare_cmake.sh --help ` for the full set of options.
3840
3941
40- ## Q2: "Does cstring have its own unit-tests?"
42+ ## Q2: "How do I install cstring?"
43+
44+ See [ INSTALL.md] ( ./INSTALL.md ) for details of how to install ** cstring** .
45+
46+
47+ ## Q3: "How do I use cstring?"
48+
49+ Include ** cstring/cstring.h** (and ** cstring/cstring.vector.h** where needed)
50+ and link against ** libcstring** (the ** CMake** target is ` cstring::core ` ).
51+ Create and destroy instances with ` cstring_create() ` / ` cstring_destroy() ` ,
52+ and mutate with ` cstring_assign() ` , ` cstring_append() ` , and related APIs.
53+
54+ A minimal sketch:
55+
56+ ``` c
57+ #include < cstring/cstring.h>
58+
59+ #include < stdio.h>
60+ #include < stdlib.h>
61+
62+ int main (void)
63+ {
64+ cstring_t cs;
65+ CSTRING_RC rc = cstring_create(&cs, "Hello");
66+
67+ if (CSTRING_RC_SUCCESS != rc)
68+ {
69+ return EXIT_FAILURE;
70+ }
71+
72+ printf("%s\n", cs.ptr);
73+
74+ cstring_destroy(&cs);
75+
76+ return EXIT_SUCCESS;
77+ }
78+ ```
79+
80+ See [INSTALL.md](./INSTALL.md) and the examples under **examples/**.
81+
82+
83+ ## Q4: "Does cstring have its own unit-tests?"
4184
4285Yes. Automated tests live under:
4386
@@ -50,7 +93,7 @@ and run with **run_all_unit_tests.sh** (and **CTest** where configured). Tests
5093require **STLSoft** and **xTests** (and may optionally recognise **shwild**).
5194
5295
53- ## Q3 : "How do I build without the C++ examples and tests?"
96+ ## Q5 : "How do I build without the C++ examples and tests?"
5497
5598Pass `--no-cpp` (or `-C`) to **prepare_cmake.sh**, which sets CMake
5699`NO_CSTRING_CPP_API=ON`. That omits C++ examples and remaining C++ tests.
@@ -59,7 +102,7 @@ The **C** unit-tests still require **STLSoft** and **xTests** unless you also
59102pass `--disable-testing` / `-T`.
60103
61104
62- ## Q4 : "Where are the examples?"
105+ ## Q6 : "Where are the examples?"
63106
64107Examples live under **examples/** (`c/` and `cpp/`), each with a short
65108**README.md**. They are built when `BUILD_EXAMPLES` is on (the default); omit
0 commit comments