PCGamingKing PCGamingKing - 4 months ago 21
C++ Question

Cin for array causing eror

First, I would like to point out that I am a novice programmer.

I am using visual studio because I like it.

I was writing a program where I was experimenting with user input into arrays, and for some unknown reason, I kept getting errors when trying to use a cin function to define an array. I shortened the code to the specific line that gave me the repeatable error.

#include "stdafx.h"
#include <iostream>

using namespace std;
int main()
int num[1][1];

cin >> num[1][1];
return 0;

I would really appreciate it if someone could explain specifically what is going wrong here and what needs to be done to fix the error or circumvent it. Thanks in advance.

Also, I don't need 500 people telling me not to use namespaces. I did this to save time in the program, and I am certain it does not affect anything in this case.

    // The size of the array is one
    int num[1][1];
    //array index starts from 0 since your size is one you can only have index 0
    cin >> num[0][0];