Chcę zrobić programik który najpierw zapisze w postaci binarnej liczbe (np. 30) do pliku, a potem z tego pliku odczyta tę liczbę i pokaże. jak to zrobić??
mam taki kod:
#include
#include
#include
using namespace std;
int main()
{
ofstream fout("example.bin", ios::binary);
int number = 30;
fout.write((char *)(&number), sizeof(number));
fout.close();
ifstream fin("example.bin", ios::binary);
fin.read((char *)(&number), sizeof(number));
cout<
getch();
}