首页 > 解决方案 > C++ 程序在某些行之后没有正确编译 [cout 语句]

问题描述

我是 C++ 新手并使用 minGW 版本 6.3.0-1。我无法编译此代码。

#include <iostream> 
#include <conio.h>

using namespace std;

int main()
{
    int r, c, a[5][5];
    cout << "Test loop";

    for (int x = 1; x <= 6; ++x)
    {
        cout << "Value of variable x is: " << x << endl;
    }

    cout << "Test loop ends" << endl;

    cout << "Enter the number of rows and columns:";
    cin >> r >> c;
    for (int i = 0; i < r; ++i)
    {
        for (int j = 0; j < c; ++j)
        {
            cout << "Enter the array element:";
            cin >> a[i][j];
        }
    }
    cout << "The array you entered:" << "\n order:" << r << "x" << c;

    for (int i = 0; i < r; ++i)
    {
        for (int j = 0; j < c; ++j)
        {
            cout << a[i][j] << "  ";
        }
        cout << endl;
    }

    return 0;
    getch();
}

还请帮助找出我当前使用的 C++ 标准。

标签: c++

解决方案


    return 0;
    getch();
}

main()等待使用getch(). 切换这两行:

    getch();
    return 0;
}

另外请帮助找出我当前使用的 C++ 标准。

如果您-std在编译代码时未指定,则 gcc 6.3 默认为 -std=gnu++14这意味着您正在使用带有 GNU 扩展的 C++14。有关更多详细信息,请参阅文档


推荐阅读