Skip to content

Instantly share code, notes, and snippets.

@warfares
Created October 9, 2013 12:17
Show Gist options
  • Save warfares/6900351 to your computer and use it in GitHub Desktop.
Save warfares/6900351 to your computer and use it in GitHub Desktop.
copy string to lower case.
#include <stdio.h>
#include <string.h>
int main() {
char *s1 = "I Used to BE An UPPER CASE StrinG\n";
/* alloc memory and copy the string (to preserve the original reference */
char *s2 = strdup(s1);
unsigned i;
for (i = 0; i < strlen(s2); i++)
s2[i] = tolower(s2[i]);
printf("%s", s1);
printf("%s", s2);
free(s2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment