MCPcopy Create free account
hub / github.com/KaisenAmin/c_std / string_front

Function string_front

string/std_string.c:1377–1385  ·  view source on GitHub ↗

* @brief Returns a pointer to the first character in the String object. * * This function returns a pointer to the first character in the String object. If the String object is NULL or empty, * the function returns NULL. * * @param str The String object to access. Must not be NULL or empty. * @return A pointer to the first character in the string, or NULL if the string is NULL or empty. */

Source from the content-addressed store, hash-verified

1375 * @return A new C-string with all characters in lowercase. The caller is responsible for freeing the allocated memory.
1376 */
1377char* string_to_lower(const String* str) {
1378 if (str != NULL) {
1379 STRING_LOG("[string_to_lower]: Converting string to lowercase.\n");
1380
1381 char* lower = (char*) malloc(sizeof(char) * (str->size + 1));
1382 if (!lower) {
1383 STRING_LOG("[string_to_lower]: Error - Failed to allocate memory.\n");
1384 return NULL;
1385 }
1386
1387 for (size_t index = 0; index < str->size; index++) {
1388 lower[index] = sstr_ascii_tolower(str->dataStr[index]);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected