#include "stdafx.h"
#include "Compiler.h"
#include <fstream>
int main() {
std::ofstream output("file.bin", std::ios::binary | std::ios::trunc);
if(output.fail()) {
return 1;
}
std::vector<unsigned char> f = Runtime::convert_line_to_instructions("rt_reg str Hello");
for(unsigned char i : f) {
//output.write(reinterpret_cast<char*>&i, sizeof(unsigned short)); doesn't work here.
}
std::cerr << "Program Compiled!" << std::endl;
while(true);
return 0;
}
How do I save an unsigned char vector to a file? I've tried several solutions (including the one that's commented out), but none of them worked.
*convert_line_to_instructions returns an unsigned char vector too.