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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:11:03+00:00 2026-05-23T12:11:03+00:00

When I try to compile my program, I get the following error: main.cpp: In

  • 0

When I try to compile my program, I get the following error:

main.cpp: In function ‘int main()’:
main.cpp:67: error: cannot convert ‘int (*)[(((long unsigned int)(((long int)mapSizeY) -      1)) + 1u)]’ to ‘int (*)[10]’ for argument ‘3’ to ‘void initializeMap(int, int, int (*)[10])’
main.cpp:68: error: cannot convert ‘int (*)[(((long unsigned int)(((long int)mapSizeY) - 1)) + 1u)]’ to ‘int (*)[10]’ for argument ‘3’ to ‘void paintMap(int, int, int (*)[10])’

My code looks like this:

#include <iostream>
using namespace std;

void initializeMap(int mapSizeX, int mapSizeY, int map[][10])
{
    // Map details:
    // 0 = # (wall)
    // 1 = space (free space)
    // 2 = x (player)

    for(int x = 0; x < mapSizeX; x++)
    {
        map[x][0] = 0;
    }

    for(int y = 0; y < (mapSizeY - 2); y++)
    {
        map[0][y] = 0;

        for(int x = 0; x < (mapSizeX - 2); x++)
        {
            map[x][y] = 1;
        }

        map[mapSizeX][y] = 0;
    }

    for(int x = 0; x < mapSizeX; x++)
    {
        map[x][mapSizeY - 1] = 0;
    }
}

void paintMap(int mapSizeX, int mapSizeY, int map[][10])
{
    for(int y = 0; y < mapSizeY; y++)
    {
        for(int x = 0; x < mapSizeX; x++)
        {   
            switch(map[x][y])
            {
                case 0:
                    cout << "#";
                    break;

                case 1:
                    cout << " ";
                    break;

                case 2:
                    cout << "x";
                    break;

            }

            cout << map[x][y];
        }
        cout << endl;
    }
}

int main()
{
    int mapSizeX = 10;
    int mapSizeY = 10;
    int map[mapSizeX][mapSizeY];
    initializeMap(mapSizeX, mapSizeY, map);
    paintMap(mapSizeX, mapSizeY, map);

    cout << endl << endl;

    return 0;
}

I’ve spent an hour trying to solve the issue and about twenty minutes searching for a solution. Can any of you help me out?

  • 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-23T12:11:04+00:00Added an answer on May 23, 2026 at 12:11 pm

    C++ does not support variable-length arrays, which is what map is in your code. However, some compilers may support it as a non-standard extension. However, it certainly won’t be compatible with a function expecting a “standard” array.

    If you make mapSizeX and mapSizeY constants, this should work.

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

Sidebar

Related Questions

I get the following error when I try to compile an asp.net site using
When I try using a Name=id and\or x:name=id I get a compiler error: The
Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
When I try to compile the newest version of Clisp on Ubuntu 8.04 I
When I try to compile code on VS 2005 and it fails, the line
Here's an interesting puzzle. I downloaded Snippet Compiler to try some stuff out, and
My compiler behaves oddly when I try to pass a fixed-size array to a
I keep getting compiler errors when I try to access flashVars in an AS3
try { ... } catch (SQLException sqle) { String theError = (sqle).getSQLState(); ... }
I try to fetch a Wikipedia article with Python's urllib: f = urllib.urlopen(http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes) s

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.