|
C-Menu 0.2.9
A User Interface Toolkit
|
Simple String Object Library. More...
Functions | |
| String | free_string (String string) |
| Free the dynamically allocated String. | |
| size_t | string_cat (String *dest, const String *src) |
| Concatenates src String to dest String, allocating additional memory for dest String if necessary. | |
| size_t | string_cpy (String *dest, const String *src) |
| Copy src String to dest String, allocating additional memory for dest String if necessary. | |
| size_t | string_ncat (String *dest, const String *src, size_t n) |
| Concatenates up to n characters from src String to dest String, allocating additional memory for dest String if necessary. | |
| size_t | string_ncpy (String *dest, const String *src, size_t n) |
| copies up to n characters from src String to dest String, allocating additional memory for dest String if necessary | |
| String | to_string (const char *s) |
| String functions provide a simple string library to facilitate string manipulation in C, allowing developers to easily create, copy, concatenate, and free strings without having to manage memory manually. | |
Simple String Object Library.
Free the dynamically allocated String.
| string | to free |
Frees the dynamically allocated string and sets length to 0.
Definition at line 1423 of file futil.c.
Concatenates src String to dest String, allocating additional memory for dest String if necessary.
Concatenates up to n characters from src String to dest String, allocating additional memory for dest String if necessary.
| dest | - destination String struct |
| src | - source String struct |
| n | - maximum number of characters to concatenate |
Definition at line 1474 of file futil.c.
copies up to n characters from src String to dest String, allocating additional memory for dest String if necessary
| dest | - destination String struct |
| src | - source String struct |
| n | - maximum number of characters to copy |
Definition at line 1495 of file futil.c.
| String to_string | ( | const char * | s | ) |
String functions provide a simple string library to facilitate string manipulation in C, allowing developers to easily create, copy, concatenate, and free strings without having to manage memory manually.
The library includes functions to convert C strings to String structs, create new String structs with specified lengths, copy and concatenate String structs, and free the memory used by String structs. By using this library, developers can avoid common pitfalls of C string handling, such as buffer overflows and memory leaks, while still benefiting from the performance advantages of C. Designed to be simple and easy to use, making it a great choice for developers who want to work with strings in C without having to worry about the complexities of manual memory management. The String struct is defined as follows:
All functions in this library that return a String struct allocate memory for the string using malloc or realloc. It is the caller's responsibility to free this memory using the free_string function when it is no longer needed to avoid memory leaks.
Convert C string to String struct
| s | C string |