如何写入二进制文件

ofstream outfile("license.lic", ios::binary); outfile.write(encodeStr, 16); outfile.close();encodeStr为CHAR*,写入结果是CC
2026年09月26日 21:38
有1个网友回答
网友(1):

#include 写二进制文件 写二进制文件应该使用ofstream类,文件的打开模式一定要是 binary,如果传入的不是 binary, 文件将以ASCII方式打开。 下面是示例代码,用于写入文件。 std::ofstream fout("a.dat", std::ios::binary); int nNum = 20; st