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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:13:17+00:00 2026-05-20T17:13:17+00:00

I am trying to (right now anyway), to display a maze from a data

  • 0

I am trying to (right now anyway), to display a maze from a data file. The first grouping of numbers is the size, the second the entrance, and the third are for the exit coordinates.

I have a simple input file named “MyMaze1.dat”:

7 20 
0 18
6 12
****************** *
*     *      ***** *
* ***** ***        *
* ***** *****   ** *
* *             *  *
* *******  *       *
************ *******

The code I use to read this maze:

void MazeClass::ReadMaze(ifstream& mazedata){
    mazedata >> row >> column;
    GetExit(mazedata);
    GetEntrance(mazedata);
    maze= new char*[row];
    for (unsigned i=0; i<row;i++)
    {
        maze[i]=new char[column];
    }
    /*
        maze=new char[column];
        *maze[i]=new char[column];
    */
    for (int y=0;y<column;y++)
    {//Keeping the maze inside boundries (step 1)
        for (int x=0;x<row;x++)//(Step 2)
        {
            maze[x][y]=mazedata.get();
        }
    }
}

and the code I use to display the maze is:

void MazeClass::Display(){
    cout << "Entrance is: " << entx << ' ' << enty << endl;
    cout << "Exit is: " << exitx << ' ' << exity << endl;
    cout << "Maze is: " << endl;
    for (int y=0;y<column;y++)
    {
        for (int x=0;x<row;x++)
        {
            cout << maze[x][y];
        }
        cout << endl;
    }
}

The output of which looks like:

Entrance is: 6 12
Exit is: 0 18
Maze is: 

******
*******
***** *

*     
*      
***** *

* ****
* ***  
      *

* ****
* *****
   ** *

* *   

   *  *

* ****
***  * 
      *

******
****** 

Thank you ahead of time for all the help.

  • 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-20T17:13:18+00:00Added an answer on May 20, 2026 at 5:13 pm
    • You’re not skipping EOL’s (\n) when reading the maze data.
    • You’re swapping x and y

    for (int y=0; y < rows; y++) // rows outer
    {
        for (int x=0;x < columns ;x++)// columns inner
        {
            maze[y][x]=mazedata.get(); // Swapped y and x
        }
        mazedata.get(); // skip \n
    }
    

    Same change’s needed for Display

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

Sidebar

Related Questions

The thing im trying to do right now is pulling in multiple links from
I'm trying to load data from an external .js file, containing a JSON representation
What I'm trying to do right now is to create an array with a
So right now I've developed an application that I'm trying to write an API
Right now I'm trying to create my own tiny MVC (just for practice and
Right now I'm trying desperately to get @font-face to work in my website. This
Right now I'm trying this: int a = round(n); where n is a double
Right now I'm trying to set the default audio device on Windows 7 programmatically,
Right now I'm trying to write a function to moving up frame when keyboard
Right now I have been trying to use Launchpad's API to write a small

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.