Hey.
Jeg har en fil.bin som indeholder et tal. Dette tal vil jeg gerne have skrevet over i en int. Hvordan skal jeg gøre dette?
Har prøvet med:
double ReadBankInt;
// ReadBank
if(YesNo == "Yes" || YesNo == "yes")
{
system("CLS");
ReadBank.open("Bank.bin");
// File size function
long end, begin;
begin = ReadBank.tellg();
ReadBank.seekg (0, ios::end);
end = ReadBank.tellg();
// __________________
if(ReadBank.is_open() )
{
while(! ReadBank.eof() )
{
ReadBank >> ReadBankInt;
}
cout << "Money: " << ReadBankInt << endl;
cout << endl << endl << "File size is: " << (end-begin) << ". Bytes" << endl;
Sleep(5000);
ReadBank.close();
}
else
{
cout << "Unable to load Bank.bin file! \nBe sure you have written something to the file, before reading it!" << endl;
Sleep(3500);
}
}