You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <sstream>
#include <string>
#include <thread>
#include <vector>
//
#include <winsock2.h>
//
#include <Windows.h>
//
#include <stdio.h>
#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<char>(ifs)), std::istreambuf_iterator<char>()); 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; }
|