Created
July 12, 2012 00:23
-
-
Save hanachin/3094673 to your computer and use it in GitHub Desktop.
プログラミング1
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> | |
#include <ctype.h> | |
char swapcase(char c) { | |
return isupper(c) ? tolower(c) : toupper(c); | |
} | |
void replace(char *src, char *dest) { | |
size_t len = strlen(src); | |
for (size_t i = 0; i < len; i++) { | |
dest[i] = swapcase(src[i]); | |
} | |
dest[len] = '¥0'; | |
} | |
int main(int argc, char *argv[]) { | |
for (int i = 0; i < argc; i++){ | |
char dest[256]; | |
replace(argv[i], dest); | |
printf("%s¥n", dest); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment