書式#include <iostreamの>
書式#include <stdio.hに>
名前空間stdを使用。
クラスにIOException {}。
クラスFileException {}。
クラスUndefineError {}。
ボイドmy_copyを(CONSTチャー* SRC_FILE、CONSTするchar * DEST_FILE)
{
FILEの*のin_file、* out_fileパラ。
=用のfopen(SRC_FILE、 "RB")in_file。
(== NULL in_file)場合
、{
)(IOExceptionをスローします。
}
out_fileパラ=用のfopen(DEST_FILE、 "WB")。
(== NULL out_fileパラ)場合
{
FileException()を投げます。
}
チャーREC [1024]。
bytes_in size_tの、bytes_out。
一方、((bytes_in =のfread(REC、1、1024 in_file))> 0)
{
bytes_out = fwriteの(bytes_in REC、1、、out_fileパラ)。
(!bytes_in = bytes_out)場合
{
)(UndefineErrorを投げます。
}
}
にfflush(out_fileパラ)。
FCLOSE(out_fileパラ)。
FCLOSE(in_file)。
}
メインINT()
{
試み
{
my_copyを( "D:\\ \\ 1.TXTファイル"、 "D:\\ \\ 20190608 \\ 1.TXTファイル");
}
キャッチ(IOExceptionをE)
{
のprintf(「例外\ N- ");
}
キャッチ(FileException E)
{
のprintf(" N- \異常な二つの");
}
キャッチ(UndefineError E)
{
のprintf("例外3 \ N- ");
}
システム(「一時停止」)。
0を返します。
}