私はC++の初心者です(C#から移行しています)ので、ここで何が起こっているのか正確にはわかりません。私がやろうとしているのは、イメージをファイルから読み込んで出力ファイルに書き込むことですが、ファイルの一部が壊れているように見えるときはいつでもそうです。fwrite()ファイルの破損C++
私はメモリ内のデータをチェックして実際に一致しています。だからこそ、fwrite()で何か起こっていなければならないと思います。 http://pastebin.com/x0eZin6K
そして、私のコード:高度で
// used to figure out if reading in one giant swoop has to do with corruption
int BlockSize = 0x200;
// Read the file data
unsigned char* data = new unsigned char[BlockSize];
// Create a new file
FILE* output = fopen(CStringA(outputFileName), "w+");
for (int i = 0; i < *fileSize; i += BlockSize)
{
if (*fileSize - i > BlockSize)
{
ZeroMemory(data, BlockSize);
fread(data, sizeof(unsigned char), BlockSize, file);
// Write out the data
fwrite(data, sizeof(unsigned char), BlockSize, output);
}
else
{
int tempSize = *fileSize - i;
ZeroMemory(data, tempSize);
fread(data, sizeof(unsigned char), tempSize, file);
// Write out the data
fwrite(data, sizeof(unsigned char), tempSize, output);
}
}
// Close the files, we're done with them
fclose(file);
fclose(output);
delete[] data;
delete fileSize;
おかげ
ここではいくつかのサンプルデータです!
Ah!初期ファイルをバイナリモードで開きましたが、出力ファイルは開きませんでした。あなたは素晴らしいです、ありがとう! – Lander