[問題] 請教關於陣列
#include "stdafx.h"
#include "iostream"
using namespace std;
int main(void)
{
int p=1;
cout<<"How many numbers?"<<endl;
cin>>p;
int A[p];
for(int i=0;i<p; i++)
{
cin>>A[i];
}
cout<<"Before sort:"<<endl;
for(int i=0;i<p; i++)
{
cout<<A[i]<<endl;
}
return 0;
}
我卻得到錯誤訊息:
.\作業1.2.cpp(9) : error C2057: 必須是常數運算式
.\作業1.2.cpp(9) : error C2466: 無法配置常數大小為 0 的陣列
,常數必須為大於 0 的整數
.\作業1.2.cpp(9) : error C2133: 'A' : 未知的大小
請問問題出在哪裡呢?
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.4.235
→
03/17 12:02, , 1F
03/17 12:02, 1F
→
03/17 12:03, , 2F
03/17 12:03, 2F
→
03/17 12:04, , 3F
03/17 12:04, 3F
推
03/17 12:24, , 4F
03/17 12:24, 4F
※ 編輯: Mason0218 來自: 140.112.4.234 (03/17 15:32)
→
03/17 15:33, , 5F
03/17 15:33, 5F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章