问题:
用C++ ofstream把int=12写入文件后,打开文件只有2字节。
std::ofstream outFile("hh.bin", std::ofstream::binary);
int a = 12;
int size = sizeof(a);
char * ap = (char *)&a;
outFile.write(ap, size);
outFile.close();
用notepad++打开看,只有0c cc两个字节
如果把int a = 123456 (0001e240)写入文件,就是4个字节
为什么12写入文件,只有2字节呢?
查阅过文件属性之后,发现占用空间是4字节。也许是notepad++的现实问题