0
Cpp simple question
I'm declaring an array (char arr[2][2] for example) and i do this: cin >> arr[1] Will it go to arr[1][0] or somwhere else? I will be so greatful if you answer it right now😊
8 odpowiedzi
+ 8
When you write like this
cin >> arr[1][0]
the compiler knows the exact position, that is where to store the value in the array, what's the row and column but when you write like this
cin >> arr[1]
Now this time compiler will get confused. It knows that it has to store the value somewhere in the second row but it does not know the column index.
So it doesn't have the exact position to store the variable and will give error asking programmer to give the exact position.
+ 6
For me it does, but if for you it doesn't just try to cout [1][0] and [1][1], and see what's the value
+ 5
It will just display error.
+ 5
It does give error
+ 5
No problem 😊, in case of char input(char array), it will work without errors
0
olek, but it doesn't
0
nautaxh, please then explane why🤔
0
Ahh, actualy i didn't mention that it is a char input not int, sorry😅