CString
CString is the type in Cangjie that represents C-style strings, corresponding to char* in C. C strings are null-terminated (ending with \0) and have a different memory layout from Cangjie's String type.
To convert a Cangjie String to CString, use the LibC.mallocCString() function, which allocates memory on the C heap and copies the string contents. The converted CString can be passed directly to C functions that accept const char*. To convert a CString back to a Cangjie String, call the toString() method.
CString provides practical member functions: size() gets the string length, isEmpty() checks if it's empty, and equals() compares two strings. The code on the right demonstrates interoperating with the C standard library function strlen.
LibC.mallocCString() allocates memory on the C heap; you must call LibC.free() to release it after use, otherwise it will cause a memory leak.Try calling other C string functions, such as strcmp or strcat.