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😊

27th Sep 2018, 5:14 PM
Oleg Storm
Oleg Storm - avatar
8 Respuestas
+ 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.
28th Sep 2018, 11:56 AM
blACk sh4d0w
blACk sh4d0w - avatar
+ 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
27th Sep 2018, 5:28 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 5
It will just display error.
27th Sep 2018, 5:25 PM
Aleksander Szczepura
Aleksander Szczepura - avatar
+ 5
It does give error
27th Sep 2018, 7:43 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 5
No problem 😊, in case of char input(char array), it will work without errors
28th Sep 2018, 2:25 PM
blACk sh4d0w
blACk sh4d0w - avatar
0
olek, but it doesn't
27th Sep 2018, 5:26 PM
Oleg Storm
Oleg Storm - avatar
0
nautaxh, please then explane why🤔
28th Sep 2018, 8:15 AM
Oleg Storm
Oleg Storm - avatar
0
Ahh, actualy i didn't mention that it is a char input not int, sorry😅
28th Sep 2018, 1:49 PM
Oleg Storm
Oleg Storm - avatar