在下面的剪辑中,我正在计算要搜索的文件的位置,以便写入。
然后我尝试打印那个位置。它返回的值不正确;printf("nXBlocks: %i nYBlocks: %i posX: %i, posY: %i, blockheight: %i, blockwidth: %i \n",
nXBlocks,nYBlocks, tilePosX, tilePosY , XBlockSize, YBlockSize );
binfile->seekp((tilePosX*poBand->GetYSize()*XBlockSize)*sizeof(uint16_t) + (tilePosY * XBlockSize*YBlockSize)*sizeof(uint16_t));
size_t pos = binfile->tellp();
cout<<"Multiplication output: "
<<(tilePosX*poBand->GetYSize()*XBlockSize)*sizeof(uint16_t) + (tilePosY * XBlockSize*YBlockSize)*sizeof(uint16_t)
<<endl;
cout << "Put pointer positions: " << pos << endl;
binfile->write((char *)&sixteenBitData, sizeof(uint16_t)*bufSizeX*bufSizeY);
我得到了
的输出放指针位置:18446744073709551615
每次调用tellp
而不是基于我传递给seekp的值的值
编辑:前几个的一些输出......
nXBlocks: 34 nYBlocks: 29 posX: 0, posY: 0, blockheight: 1024, blockwidth: 1024
Multiplication output: 0
Put pointer positions: 0
nXBlocks: 34 nYBlocks: 29 posX: 0, posY: 1, blockheight: 1024, blockwidth: 1024
Multiplication output: 2097152
Put pointer positions: 18446744073709551615
nXBlocks: 34 nYBlocks: 29 posX: 0, posY: 2, blockheight: 1024, blockwidth: 1024
Multiplication output: 4194304
Put pointer positions: 18446744073709551615
答案 0 :(得分:0)
binfile.bad()