You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working on converting save and load files to binary and back. I have copied my professors code line by line for this function but it isn't working. Help?? I am using VS 2022. New to gitHub, sorry.
#include<cstdio>
#include<chrono>
#include<cmath>
#include<filesystem>
#include<fstream>
#include<iostream>
#include<iomanip>
#include<limits>
#include<random>
#include<string>
#include<cctype>using std::cout;
using std::endl;
using std::cin;
using std::string;
using std::random_device;
using std::uniform_int_distribution;
using std::chrono::high_resolution_clock;
using std::chrono::duration;
using std::ios;
using std::ifstream;
using std::ofstream;
using std::string;
using std::numeric_limits;
using std::streamsize;
using std::getline;
using std::ios;
voidloadGame() {
validateInventory();
using std::filesystem::current_path;
using std::filesystem::path;
using std::filesystem::exists;
//build the absolut4e file path and keep going if it already exists
path filePath{ current_path().append(SAVEFILE) };
if (exists(filepath)) {
cout << filepath.string();
if (fileStream.is_open()) filestream.close();
switch (fileFormat)
{
case TEXT:
{
filestream.open(filepath, ios::in);
if (filestream.good())
{
//integer status data
fileStream << status.miles << endl;
fileStream << status.turn << endl;
fileStream << status.oxen << endl;
fileStream << status.food << endl;
fileStream << status.ammo << endl;
fileStream << status.clothes << endl;
fileStream << status.misc << endl;
fileStream << status.cash << endl;
fileStream << fortAvailable << endl;
//boolean status data
fileStream << status.blueMountainsCleared << endl;
fileStream << status.haveIllness << endl;
fileStream << status.haveInjury << endl;
fileStream << status.isDead << endl;
fileStream << status.southPassCleared << endl;
// choice data
fileStream << choice.eat << endl;
fileStream << choice.turn << endl;
fileStream << choice.action << endl;
}
break;
}
case BINARY:
{
fileStream.open(SAVEFILE, ios::out | ios::binary);
fileSystem.write(reinterperet_cast<char*>(&status), sizeof(status));
fileSystem.write(reinterperet_cast<char*>(&choice), sizeof(choice));
}
}
fileStream.close();
}
}
The text was updated successfully, but these errors were encountered:
I am currently working on converting save and load files to binary and back. I have copied my professors code line by line for this function but it isn't working. Help?? I am using VS 2022. New to gitHub, sorry.
The text was updated successfully, but these errors were encountered: