Skip to content

Instantly share code, notes, and snippets.

@hanachin
Created July 12, 2012 00:23
Show Gist options
  • Save hanachin/3094673 to your computer and use it in GitHub Desktop.
Save hanachin/3094673 to your computer and use it in GitHub Desktop.
プログラミング1
#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