Created
October 8, 2023 22:26
-
-
Save denisdemaisbr/789895f3d1aeb3cf0f7690318774f9eb to your computer and use it in GitHub Desktop.
a simple function to duplicate string and lower it.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char* strdup_lower(char* str) { | |
char *b; | |
char *s; | |
char *buf; | |
errno = 0; | |
buf = strdup(str); | |
if (!buf) | |
return NULL; | |
b = buf; | |
s = str; | |
while(*b) { | |
*b++ = tolower(*s++); | |
} | |
errno = 0; | |
return buf; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment