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.
 
 
 
 

54 lines
1.2 KiB

#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[]) {
// 打开 0.bin
// 读取 0.bin 到数组中
// 每次读9byte
// 3byte 3byte 3byte
// 存放到0.csv中
std::ifstream ifs("0.bin", std::ios::binary);
if (!ifs) {
std::cerr << "open 0.bin failed" << std::endl;
return -1;
}
std::ofstream ofs("0.csv", std::ios::binary | std::ios::trunc);
if (!ofs) {
std::cerr << "open 0.csv failed" << std::endl;
return -1;
}
char buf[9];
while (ifs.read(buf, 9)) {
unsigned int a = 0;
unsigned int b = 0;
unsigned int c = 0;
a = (unsigned char)buf[0] | (unsigned char)buf[1] << 8 | (unsigned char)buf[2] << 16;
b = (unsigned char)buf[3] | (unsigned char)buf[4] << 8 | (unsigned char)buf[5] << 16;
c = (unsigned char)buf[6] | (unsigned char)buf[7] << 8 | (unsigned char)buf[8] << 16;
ofs << a << "," << b << "," << c << std::endl;
}
return 0;
}