我正在将几个较小的文件编译成一个大文件。
我试图让每个小文件都以一定的粒度开始,在我的例子中是 4096。
因此,我正在填补每个文件之间的空白。
为此,我使用了
//Have a look at the current file size
unsigned long iStart=ftell(outfile);
//Calculate how many bytes we have to add to fill the gap to fulfill the granularity
unsigned long iBytesToWrite=iStart % 4096;
//write some empty bytes to fill the gap
vector <unsigned char>nBytes;
nBytes.resize(iBytesToWrite+1);
fwrite(&nBytes[0],iBytesToWrite,1,outfile);
//Now have a look at the file size again
iStart=ftell(outfile);
//And check granularity
unsigned long iCheck=iStart % 4096;
if (iCheck!=0)
{
DebugBreak();
}
但是 iCheck 返回
iCheck = 3503
我预计它是0。
有人看到我的错误吗?