ショートパンツの単一のブロックを割り当て、それをファイルにfwriteしてから、読み戻そうとしています。しかし、ファイルに書き込まれるデータは、出力されるデータと一致しません。問題を次のコードに切り分けました。私が間違っていることについて何か考えはありますか?
#define CHUNK_SIZE 1000
void xwriteStructuresToFile(FILE *file, void * structureData)
{
assert((fwrite(structureData, sizeof(short), CHUNK_SIZE, file)) == CHUNK_SIZE);
}
void wwbuildPtxFiles(void)
{
FILE *file = fopen("s:\\tv\\run32\\junky.bin", WRITE_BINARY);
int count = 10;
short *ptx = (short *) calloc(CHUNK_SIZE * count, sizeof(short ) );
memset(ptx, '3', sizeof(short) * CHUNK_SIZE * count);
for (int dayIndex = 0; dayIndex < count; ++dayIndex)
xwriteStructuresToFile(file, (void *) &ptx[ CHUNK_SIZE * sizeof(short) * dayIndex ]);
free(ptx);
fclose(file);
file = fopen("s:\\tv\\run32\\junky.bin", READ_BINARY);
int xcount = CHUNK_SIZE * count * sizeof(short );
for (int i = 0; i < xcount; ++i)
{
char x;
if ((x = getc(file)) != '3')
assert(false);
}
}