【问题标题】:Why does code work in codeblocks 16.01 but doesn't i the newest version of Clion为什么代码在代码块 16.01 中可以工作,但最新版本的 Clion 不能
【发布时间】:2020-10-16 21:49:42
【问题描述】:
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
int r,k;

    cout << "Unesite broj redova:";
    cin >> r;
    cout << endl << "Unesite broj kolona:";
    cin >> k;

int A[r][k];

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

} 在使用代码块 6 个月后,我是 clion 的新手。我有一个 clion liscenes,我打开了我开始在代码块中编写的代码,我不想在 clion 中工作。 感谢所有帮助

【问题讨论】:

    标签: c++ codeblocks clion


    【解决方案1】:

    这个结构

    int A[r][k];
    

    称为可变长度数组 (VLA),不是 C++ 的一部分。有些编译器将其作为扩展提供,有些则不提供。

    您应该使用 newstd::vector 或任何其他构造,而不是 VLA。

    例如,对于向量,A 变为:

    std::vector<std::vector<int>> A(r, vector<int>(k, 0));
    

    其余的保持不变。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-29
      • 2018-05-17
      • 1970-01-01
      • 2016-01-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多