0
首先,我想指出我是一個新手程序員。Cin引起錯誤的數組
我正在使用visual studio,因爲我喜歡它。
我正在編寫一個程序,我正在試驗用戶輸入到數組中,並且由於某些未知原因,我在嘗試使用cin函數定義數組時遇到了錯誤。我將代碼縮短到了給出可重複錯誤的特定行上。
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int num[1][1];
cin >> num[1][1];
return 0;
}
我真的很感激,如果有人可以具體解釋是怎麼回事錯在這裏和做什麼需要修復錯誤或繞過它。提前致謝。
此外,我不需要500人告訴我不要使用名稱空間。我這樣做是爲了節省時間,並且我確信它在這種情況下不會影響任何事情。
數組是零索引。 num [1] [1]正在調用第二行的第二列(依賴於平臺)。你想要的是num [0] [0] – Incomputable
@Olzhas非常感謝你! – PCGamingKing