-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.c
More file actions
51 lines (39 loc) · 1.17 KB
/
Copy pathmain.c
File metadata and controls
51 lines (39 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/* /////////////////////////////////////////////////////////////////////////
* File: examples/c/example.c.cstring_create/main.c
*
* Purpose: Minimal example of `cstring_create()` / `cstring_destroy()`.
*
* Created: ...
* Updated: 2nd August 2026
*
* ////////////////////////////////////////////////////////////////////// */
/* cstring header files */
#include <cstring/cstring.h>
/* Standard C header files */
#include <stdio.h>
/* /////////////////////////////////////////////////////////////////////////
* main()
*/
int main(int argc, char* argv[])
{
cstring_t cs;
CSTRING_RC rc = cstring_create(&cs, "String-#1");
((void)&argc);
((void)&argv);
if (CSTRING_RC_SUCCESS != rc)
{
fprintf(stderr, "failed to create string: %s\n", cstring_getStatusCodeString(rc));
}
else
{
printf(
"successfully created string with length %lu capacity %lu and contents '%.*s'\n"
, (unsigned long)cs.len
, (unsigned long)cs.capacity
, (int)cs.len, cs.ptr
);
cstring_destroy(&cs);
}
return 0;
}
/* ///////////////////////////// end of file //////////////////////////// */