ページ 1 / 1
無題
Posted: 2009年10月23日(金) 11:26
by rajan
in.txt から out.txt に 内容をコピするプログラム作り方教えてください
Re:無題
Posted: 2009年10月23日(金) 11:29
by kazuoni
すべてin.txtから文字を読み込んでout.txtに出力してください
としか言いようがない気が^^;
規約をもう一度読んで、不足しているところは追記してください。
もっとよりよい回答が得られると思います。
Re:無題
Posted: 2009年10月23日(金) 11:46
by Ma
Windows API つかっていいなら、
CopyFile()
この関数でいっぱつ。
Re:無題
Posted: 2009年10月23日(金) 12:02
by バグ
C++でSTLを使うならば…
std::ifstream ifstm("in.txt");
std::ofstream ofstm("out.txt");
std::copy(std::istreambuf_iterator<char>(ifstm), std::istreambuf_iterator<char>(), std::ostream_iterator<char>(ofstm));
こんな感じ?
Re:無題
Posted: 2009年10月23日(金) 12:31
by toyo
OSやコンパイラーは何でしょうか
他に条件とかありませんか
#include <stdlib.h>
int main()
{
system("cat in.txt > out.txt");
system("cp in.txt out2.txt");
return 0;
}
WindowsやLinuxなら↑でも出来ると思いますが
Re:無題
Posted: 2009年10月23日(金) 12:54
by バグ
C標準ライブラリなら、こんな感じかな?
FILE* pin = fopen("in.txt", "r");
FILE* pout = fopen("out.txt", "w");
int buf = '\0';
while ((buf = fgetc(pin)) != EOF) fputc(buf, pout);
fclose(pin);
fclose(pout);
Re:無題
Posted: 2009年10月23日(金) 19:19
by 初級者
どうしてもCのプログラムを書かねばなりませんか?
Re:無題
Posted: 2009年10月24日(土) 01:07
by lbfuvab
winXPなら
system("copy in.txt out.txt");
でいいんじゃないですか?