C/C++の宿題を片付け ..
[2ch|▼Menu]
80:デフォルトの名無しさん
07/05/15 10:10:08
>>27
今更だけどC++化した。1.5秒ほどで終了する。

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <iomanip>
int main(void)
{
char hexstr[256][3];
char *fname_in = "in.dat", *fname_out = "out.dat";
unsigned char buf[32 * 1024];
int i;
std::ostringstream str;
str << std::hex << std::uppercase;
for (i = 0; i < 256; i++) {
str << std::setw(2) << std::setfill('0') << i << '\0';
}
str << std::dec << std::nouppercase;
std::memcpy(hexstr, str.str().c_str(), 256 * 3);
std::ifstream fp_in(fname_in, std::ios::in | std::ios::binary);
std::ofstream fp_out(fname_out, std::ios::out | std::ios::trunc);
if (!fp_in || !fp_out)
return 1;
for (;;) {
if (!fp_in.get(reinterpret_cast<char*>(buf), sizeof(buf)))
break;



次ページ
最新レス表示
スレッドの検索
類似スレ一覧
話題のニュース
おまかせリスト
▼オプションを表示
暇つぶし2ch

4178日前に更新/299 KB
担当:undef