I would like to write short int x = 0x4740 to binary file in this form: 0100 0000 0100 0111 which is @G when i open it in notepad. It's working. When i try to write for example short int a = 0xf0ff; (binary: 1111 0000 1111 1111), notepad shows me ˙đ which is not really my number binary (˙đ is 1100 1011 1001 1001 1100 0100 1001 0001). How can write it and get 1111 0000 1111 1111 in this file?
Im using this converter: http://www.binaryhexconverter.com/binary-to-ascii-text-converter
int main() {
ofstream plik;
plik.open("D:\\book.dat", ios::binary);
if (!plik.good()) cout << "error";
short int x = 0xf0ff;
plik.write(reinterpret_cast<char*>(&x), 2);
plik.close();
system("pause");
return 0;
}