#include #include #include #include #include #include #include #include #include #include #include // #include // #include // #include #pragma comment(lib, "ws2_32.lib") #define PORT 8988 int main(int argc, char *argv[]) { /** * @brief * 打开raw.txt * 读取raw.txt全部内容 * 去掉换行,空格,回车 * 将16进制字符串转换成二进制 * 写入raw.bin */ std::ifstream ifs("raw.txt"); std::string str((std::istreambuf_iterator(ifs)), std::istreambuf_iterator()); ifs.close(); std::string str2; for (auto &c : str) { if (c == ' ' || c == '\n' || c == '\r') { continue; } str2.push_back(c); } std::ofstream ofs("raw.bin", std::ios::binary); for (size_t i = 0; i < str2.size(); i += 2) { std::string str3 = str2.substr(i, 2); char c = (char)std::stoi(str3, nullptr, 16); ofs.write(&c, 1); } ofs.close(); return 0; }