I'm trying to write the following bytes to a file [03 00 01 00 FF 00 00 00 FF 00 00 00 FF] but I keep getting the following bytes added to the end [03 01 0F C0 00 08 00 A0 00 C7 00 00 00 02 00 70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00] I've read up, and I've been told to use std::ios::binary when opening the file, which doesn't seem to help Here's my code
#include <fstream>
#include <iostream>
#include <conio.h>
#include <iomanip>
using namespace std;
int main() {
int height = 1,
length = 3;
int data[] = {
0x3,0x0,0x1,0x0,
0xff, 0x0, 0x0,
0x0, 0xff, 0x0,
0x0, 0x0, 0xff
};
ofstream file("thing.dki", std::ios::binary);
for(int i = 0; i < sizeof(data); i++) {
file.write((char*) &data[i], 1);
}
file.close();
return 0;
}
Aucun commentaire:
Enregistrer un commentaire