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 6932809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:45:09+00:00 2026-05-27T11:45:09+00:00

Edit: I was being dumb, I -WASN’T- allocating it. Thanks again for the help!

  • 0

Edit: I was being dumb, I -WASN’T- allocating it. Thanks again for the help!

This is an error I had thought myself to be over, yet it’s back at it, and I do not know why it’s happening.

Here is the code from the .C file leading up to the error:

int main(int argc, char* argv[])
{
    if( argc > 3 )
    {
        cout << "Too many arguments. Program will close.\n";
        return 1;
    }
     
    else
    {
        int numRooms = 0;
        int start = 0;
        ifstream file;
    
        if( argc == 3 )//Dump wanted
            file.open( argv[ 2 ] , ifstream::in );
        
        else 
            file.open( argv[ 1 ] , ifstream::in );
    

        if( file.is_open() )
        {
            file >> numRooms;
            Graph * maze = new Graph( numRooms );

The Graph * maze = new Graph( numRooms ); is where the error is being referenced (a11.C:41):

==17900== Use of uninitialised value of size 4
==17900==    at 0x8048F05: Graph::Graph(int) (Graph.C:25)
==17900==    by 0x8048C1D: main (a11.C:41)

From here we delve deeper, into the Graph.C file, lines 16 – 30:

Graph::Graph( int num )
{
    numRooms = num;
    _index = 0;
    _start = 0;

    easyDelete = new Room*[ num ];
    escapePath = new string[ num ];

    theWALL -> myNumber = -1;
    theWALL -> visited = true;

    safety -> myNumber = 0;
    safety -> visited = false;
}

Line 25 is this: theWALL -> myNumber = -1;

"theWALL" and "safety" are both private *Room objects:

Private:
    Room * theWALL;
    Room * safety;

The struct "Room" looks like this:

struct Room
    {
        bool visited;
        int myNumber;

        Room *North;
        Room *East;
        Room *South;
        Room *West;
    };

It’s initialized up when I call new Graph( numRooms ), and I am filling it it’s information… yet I get this error.

  • 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-27T11:45:10+00:00Added an answer on May 27, 2026 at 11:45 am

    Looks like you are not allocating

    Room * theWALL;
    

    before using it at

    theWALL -> myNumber = -1;
    

    try something like

    theWall = new Room();
    theWALL -> myNumber = -1;
    

    And you have the same bug for:

     Room * safety;
    

    try allocating that too.

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

Sidebar

Related Questions

Edit: Seems numerous people think this is a dumb idea, so I would appreciate
EDIT: Problem solved. This was (yet another) situation where the problem wasn't really where
edit It appears that this is just a case of the sample code being
EDIT: Ok I am a bit closer but still need help... http://pastebin.com/9vdhGT2V Disclaimer: This
How do some programs edit whats being displayed on the terminal (to pick a
I have a edit View - Product/Edit/1 1 being the Id of the Product.How
Edit: This question was written in 2008, which was like 3 internet ages ago.
EDIT: This was formerly more explicitly titled: - Best solution to stop Kontiki's KHOST.EXE
EDIT: This question is more about language engineering than C++ itself. I used C++
I feel dumb for not knowing this, but I see a lot of links

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.