cstring · Section 3
cstring_substring
NAME
cstring_substring - create a new string from a sub-range
LIBRARY
C Collections (libccollections, -lccollections)
SYNOPSIS
#include <ccollections/cstring.h> cstr cstring_substring(cstr s, size_t start, size_t length, char **err);
DESCRIPTION
This function allocates a new cstring that holds the characters in the range [start, start + length). When start + length goes past the end of the string the range is clamped to the real end, and when start is at or past the length of the string you get an empty cstring.
PARAMETERS
s Source string start Zero-based start index length Number of characters to include err Optional pointer to receive an error string on failure
RETURN VALUE
A new cstring on success NULL when an allocation fails, with the details written to *err when err is not NULL
NOTES
You must destroy the returned cstring once you are done with it Asserts if s is NULL