C/C++の宿題を片付けます 104代目at TECH
C/C++の宿題を片付けます 104代目 - 暇つぶし2ch468:デフォルトの名無しさん
08/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;
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch