Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7033545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:04:43+00:00 2026-05-28T01:04:43+00:00

I made a text adventure with a load/save option. In the folder I created

  • 0

I made a text adventure with a load/save option.
In the folder I created the game it worked fine. And even if I do a release version of my game it all works how it should.

But I have to give this project to my professor.
On my PC the saving and loading works fine but on my laptop or a copy of my projectfolder, i get the errormessage “a buffer overrun has accured”.
So what’s my fault here?

My Code to load/save:

bool save()
{
    char sFileText[1024];
    char sFileName[80];
    char sFileDirectory[80];

     GetCurrentDirectory(512, sFileDirectory); 

    sprintf(sFileName, "%s\\save_game.ini", sFileDirectory);

    sprintf(sFileText, "[settings]\n\rsp_loop=%i\n\rroom_iSelect=%i\n\riSelect=%i\n\rraum=%i\n\rtor402=%i\n\rwegiSelect=%i\n\rwegweiser=%i\n\rlight=%i\n\ropen_door=%i\n\rmesser=%i\n\rmesserwurf=%i\n\rkamera=%i\n\rstein=%i\n\ralive=%i\n\rpfeil=%i\n\rluke=%i\n\rkuehlschrank=%i\n\rpulver_schmand=%i\n\rteddy=%i\n\rseil=%i\n\rgiftklinge=%i\n\r",
         sp_loop,
         room_iSelect,
         iSelect,
         raum,
         tor402,
         wegiSelect,
         wegweiser,
         light,
         open_door,
         messer,
         messerwurf,
         kamera,
         stein,
         alive,
         pfeil,
         luke,
         kuehlschrank,
         pulver_schmand,
         teddy,
         seil,
         giftklinge
        );


    int cur_char;
    FILE *out_file;

    out_file = fopen(sFileName, "w");
    if (!out_file == NULL) 
    {
        for (cur_char = 0; cur_char < strlen(sFileText); ++cur_char) 
        {
            fputc(sFileText[cur_char], out_file);
        }
    }
    else
    {
        return false;
    }

    fclose(out_file);
    return true;
}

bool open()
{
    char sFileText[1024];
    char sFileName[12];
    char sFileGameSettingsIni[80];

    sprintf(sFileName, "save_game.ini");



    GetCurrentDirectory(512, sFileGameSettingsIni); 

    sprintf(sFileGameSettingsIni, "%s\\%s", sFileGameSettingsIni, sFileName);

    sp_loop = GetPrivateProfileInt("settings", "sp_loop", 512, sFileGameSettingsIni);

    raum = GetPrivateProfileInt("settings", "raum", 512, sFileGameSettingsIni);
    tor402 = GetPrivateProfileInt("settings", "tor402",512, sFileGameSettingsIni);
    wegiSelect = GetPrivateProfileInt("settings", "wegiSelect", 512, sFileGameSettingsIni);
    wegweiser = GetPrivateProfileInt("settings", "wegweiser", 512, sFileGameSettingsIni);
    light = GetPrivateProfileInt("settings", "light", 512, sFileGameSettingsIni);
    open_door = GetPrivateProfileInt("settings", "open_door",512, sFileGameSettingsIni);
    messer = GetPrivateProfileInt("settings", "messer", 512, sFileGameSettingsIni);
    messerwurf = GetPrivateProfileInt("settings", "messerwurf", 512, sFileGameSettingsIni);
    kamera = GetPrivateProfileInt("settings", "kamera", 512, sFileGameSettingsIni);
    stein = GetPrivateProfileInt("settings", "stein", 512,sFileGameSettingsIni);
    alive = GetPrivateProfileInt("settings", "alive", 512,sFileGameSettingsIni);
    pfeil = GetPrivateProfileInt("settings", "pfeil", 512, sFileGameSettingsIni);
    luke = GetPrivateProfileInt("settings", "luke", 512,  sFileGameSettingsIni);
    kuehlschrank = GetPrivateProfileInt("settings", "kuehlschrank", 512, sFileGameSettingsIni);
    pulver_schmand = GetPrivateProfileInt("settings", "pulver_schmand", 512, sFileGameSettingsIni);
    teddy = GetPrivateProfileInt("settings", "teddy", 512, sFileGameSettingsIni);
    seil = GetPrivateProfileInt("settings", "seil", 512, sFileGameSettingsIni);
    giftklinge = GetPrivateProfileInt("settings", "giftklinge",512, sFileGameSettingsIni);

    return true;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:04:44+00:00Added an answer on May 28, 2026 at 1:04 am

    You define sFileName as sFileName[12] and then attempt to write 14 bytes to it (13 and a NULL). It also looks like the buffer you are passing to GetCurrentDirectory() isn’t big enough. You are stating the buffer is 512 bytes in length, when you only define it as 80 characters wide.

    The return value of GetCurrentDirectory() will inform you of how large the buffer needs to be.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to monitor all text selections made in any application by the user.
Hey so i've made a text game using the pdCurses library and microsoft opperating
I've got a text scrollbox made with JQuery. It works fine when on its
I recently upgraded to flashplayer 11 and found that it made all the text
I made a game over text appears at the end of the game and
I have a text file made of 3 lines: Line 1 Line 3 (Line
This is simple text detection video made using an opencv. Any ideas how was
I'm looking for a pre-made content/text filter plugin that checks (as the user types
i had made a program for text to speech convertion in python..and now want
i made 2 views and i want to send text of label on main

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.