Skip to content

Instantly share code, notes, and snippets.

@denisdemaisbr
Created October 8, 2023 22:26
Show Gist options
  • Save denisdemaisbr/789895f3d1aeb3cf0f7690318774f9eb to your computer and use it in GitHub Desktop.
Save denisdemaisbr/789895f3d1aeb3cf0f7690318774f9eb to your computer and use it in GitHub Desktop.
a simple function to duplicate string and lower it.
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