Skip to content

Instantly share code, notes, and snippets.

@stackprogramer
Created January 13, 2017 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stackprogramer/318dc02af7df83cfe1664596dcebd1ac to your computer and use it in GitHub Desktop.
Save stackprogramer/318dc02af7df83cfe1664596dcebd1ac to your computer and use it in GitHub Desktop.
convert int8_t array to binary file, you can see binary file with wxHexEditor,C++
#include <iostream>
#include <fstream>
#include <string>
#include <iostream>
#include"sajad_Math_lab"
#include <stdint.h>
#include <stdio.h>
using namespace std;
int main (int argc, char* argv[]){
const char* FILENAM = "a.txt";
int8_t toStore[45]={1,2,3,4,5};
ofstream o(FILENAM,ios::binary);
for(int i;i<10;i++)
{
o.write((char*)toStore,sizeof(toStore));
o.close();
}
ifstream i(FILENAM,ios::binary);
//i.read((char*)&toRestore,sizeof(toRestore));
//cout << toRestore << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment