Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why am i getting E0276 and like 70 other errors? Heres some parts of my code, it is a recreation of the 1975 Oregon trail game. #1409

Closed
Bb-gun75 opened this issue Nov 22, 2024 · 1 comment

Comments

@Bb-gun75
Copy link

Bb-gun75 commented Nov 22, 2024

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;

void loadGame() {
   
    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();
           
    }
}
@Bb-gun75
Copy link
Author

I figured it out... mostly. Wrong c++ version. Still saying fileStream is unidentified though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants