- 468 名前:デフォルトの名無しさん mailto:sage [2008/02/28(木) 00:26:20 ]
- // >>467
#include <stdio.h> #include <string.h> static void flip(char * str) { char * tail = strchr(str, '\n'); if (tail == NULL) tail = strchr(str, '\0'); for (--tail; str < tail; ++str, --tail) { char foo = * str; * str = * tail; * tail = foo; } } static void flipCat(const char * fileName) { FILE * fp = fopen(fileName, "r"); char buf[1000]; while (fgets(buf, sizeof(buf), fp) != NULL) { flip(buf); fputs(buf, stdout); } fclose(fp); } int main(int argc, char ** argv) { for (int ic = 1; ic < argc; ++ic) { flipCat(argv[ic]); } return 0; }
|

|