C++ .exe不显示“;按任意键继续……”;

C++ .exe不显示“;按任意键继续……”;,c++,C++,在VisualStudio中,每当我未调试就启动时,显示的.exe文件不会像通常那样包含短语“按任意键继续…”。屏幕的开头只有闪烁的光标。有什么简单的解决办法吗?我已经注释掉了我的一些代码,短语显示了back up 这是我注释掉的代码:我正确声明了所有变量和类 void Maze::addPaths() { Coordinate currentLocation; Coordinate startLocation; Coordinate endLocation; //not

在VisualStudio中,每当我未调试就启动时,显示的.exe文件不会像通常那样包含短语“按任意键继续…”。屏幕的开头只有闪烁的光标。有什么简单的解决办法吗?我已经注释掉了我的一些代码,短语显示了back up

这是我注释掉的代码:我正确声明了所有变量和类

void Maze::addPaths()
{
    Coordinate currentLocation;
    Coordinate startLocation;
    Coordinate endLocation; //not used yet
    std::stack<Coordinate> stack;

    currentLocation.row = (((rand() % HEIGHT) / 2) * 2);
    currentLocation.column = (((rand() % WIDTH) / 2) * 2);

    startLocation = currentLocation;
    grid[currentLocation.row][currentLocation.column] = START;
    player = currentLocation;
    do 
    {
        //drawMaze();
        bool canMoveUp = !(currentLocation.row == 0 || grid[currentLocation.row - 2][currentLocation.column] != WALL);
        bool canMoveDown = !(currentLocation.row == HEIGHT - 1 || grid[currentLocation.row + 2][currentLocation.column] != WALL);
        bool canMoveLeft = !(currentLocation.column == 0 || grid[currentLocation.row][currentLocation.column - 2] != WALL);
        bool canMoveRight = !(currentLocation.column == WIDTH - 1 || grid[currentLocation.row][currentLocation.column + 2] != WALL);

        if (canMoveUp || canMoveDown || canMoveLeft || canMoveRight)
        {
            stack.push(currentLocation);

            //choose random location to dig
            bool moveFound = false;
            while (!moveFound)
            {
                int direction = rand() % 4;
                if (direction == 0 && canMoveUp)
                {
                    moveFound = true;
                    grid[currentLocation.row - 2][currentLocation.column] = PATH;
                    grid[currentLocation.row - 1][currentLocation.column] = PATH;
                    currentLocation.row -= 2;
                }
                else if (direction == 1 && canMoveDown)
                {
                    moveFound = true;
                    grid[currentLocation.row + 2][currentLocation.column] = PATH;
                    grid[currentLocation.row + 1][currentLocation.column] = PATH;
                    currentLocation.row += 2;
                }
                else if (direction == 2 && canMoveLeft)
                {
                    moveFound = true;
                    grid[currentLocation.row][currentLocation.column - 2] = PATH;
                    grid[currentLocation.row][currentLocation.column - 1] = PATH;
                    currentLocation.column -= 2;
                }
                else if (direction == 3 && canMoveRight)
                {
                    moveFound = true;
                    grid[currentLocation.row][currentLocation.column + 2] = PATH;
                    grid[currentLocation.row][currentLocation.column - 2] = PATH;
                    currentLocation.column += 2;
                cout << "yay";
                }
            }
        }
        else if (!stack.empty())
        {
            currentLocation = stack.top();
            stack.pop();
        }
    } while (!stack.empty());
    //addDestinationToGrid();
    cout << "no";
}
void Maze::addpath()
{
坐标定位;
协调定位;
坐标endLocation;//尚未使用
std::堆栈;
currentLocation.row=((rand()%高度)/2)*2);
currentLocation.column=((rand()%WIDTH)/2)*2);
位置=当前位置;
网格[currentLocation.row][currentLocation.column]=开始;
播放器=当前位置;
做
{
//drawMaze();
bool canMoveUp=!(currentLocation.row==0 | | grid[currentLocation.row-2][currentLocation.column]!=WALL);
bool canMoveDown=!(currentLocation.row==高度-1 | |网格[currentLocation.row+2][currentLocation.column]!=墙);
bool canMoveLeft=!(currentLocation.column==0 | | grid[currentLocation.row][currentLocation.column-2]!=WALL);
bool canMoveRight=!(currentLocation.column==宽度-1 | |网格[currentLocation.row][currentLocation.column+2]!=墙);
如果(canMoveUp | | canMoveDown | | canMoveLeft | | canMoveRight)
{
stack.push(当前位置);
//选择任意位置进行挖掘
bool-moveFound=false;
而(!movefind)
{
int direction=rand()%4;
如果(方向==0&&CANMOVERUP)
{
movefind=true;
网格[currentLocation.row-2][currentLocation.column]=路径;
网格[currentLocation.row-1][currentLocation.column]=路径;
currentLocation.row-=2;
}
else if(方向==1&&canMoveDown)
{
movefind=true;
网格[currentLocation.row+2][currentLocation.column]=路径;
网格[currentLocation.row+1][currentLocation.column]=路径;
currentLocation.row+=2;
}
else if(方向==2&&canMoveLeft)
{
movefind=true;
网格[currentLocation.row][currentLocation.column-2]=路径;
网格[currentLocation.row][currentLocation.column-1]=路径;
currentLocation.column-=2;
}
else if(方向==3&&canMoveRight)
{
movefind=true;
网格[currentLocation.row][currentLocation.column+2]=路径;
网格[currentLocation.row][currentLocation.column-2]=路径;
currentLocation.column+=2;
cout在Windows上,
系统(“暂停”);
将向用户提示以下文本:

Press any key to continue...
在Windows上,
系统(“暂停”);
将向用户提示以下文本:

Press any key to continue...

似乎您的主
边做边做
循环是无止境的循环。您如何初始化网格?

似乎您的主
边做边做
循环是无止境的循环。您如何初始化网格?

问题在于,我超出了名为grid的数组的边界,并且我还混淆了for循环中的行和列.

问题是,我超出了名为grid的数组的边界,并且在for循环中混淆了我的行和列。

调试器显示该提示符。因此,没有调试器它就不存在。调试器显示该提示符。因此,没有调试器它就不存在。我使用以下命令初始化网格:char grid[WIDTH][HEIGHT];(其中WIDTH和HEIGHT是常量整数。@bolovI表示存储在网格中的值。在代码方向上始终等于0。这意味着它
canMoveUp
get false,并且至少有一个
canMove…
变量在内部
中为true,(!movefind)
循环没有一个条件不被执行。因此
currentLocation
不执行步骤,在下一次迭代中
do while
循环将被检查到同一点。在条件下
currentLocation.row==0 | | grid[currentLocation.row-2][currentLocation.column]!=WALL
如果行等于1,则
grid[-1][col
仍然可以超过
网格
内存边界。类似地,对于otherI,我使用以下命令初始化网格:char grid[WIDTH][HEIGHT];(其中宽度和高度是常量整数。@bolovI表示存储在网格中的值。在代码方向上始终等于0。这意味着它
canMoveUp
get false,并且在(!moveFound)内部
中至少有一个
canMove…
变量get true)
循环没有一个条件不被执行。因此
currentLocation
不执行步骤,在下一次迭代中
do while
循环将被检查到同一点。在条件下
currentLocation.row==0 | | grid[currentLocation.row-2][currentLocation.column]!=WALL
如果行等于1,则
grid[-1][col
仍然可以超过
网格
内存边界。对于其他