Created
October 9, 2013 12:17
-
-
Save warfares/6900351 to your computer and use it in GitHub Desktop.
copy string to lower case.
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
#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