您好聲明數組大小我有下面的代碼,錯誤顯示爲「表達必須有一個常數值」當整數變量被用於C++
# include <iostream>
# include <limits>
using namespace std;
int main()
{
int runs,innings,timesnotout,n;
cout<<"Enter the number of players:";
cin>>n;
const char name[n][10]; //here error shows as "Expression must have a constant value" is displayed
}
我試圖獲取從輸入的n值,然後使用作爲數組大小的n值
的載體中。可變長度數組不是標準的。 – chris
並使用'std :: string' – olevegard
所以使用'std :: vector names(n);' –
Jarod42