Strength in my code is not updating
it changed after working after int array to char ,but according to me it should also work because of implicit type casting
The thing is that it doesn’t work when you are taking input directly from input stream, just try to print a[i][j]
,it shows 0. So you had to take input as a char only. You could have done something like this
int a[2][2];
char x;
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++) cin >> x, a[i][j] = x, cout << a[i][j];
But directly taking it from input stream like this
int a[2][2];
for (int i = 0; i < 2; i++)
for (int j = 0; j < 2; j++) cin >> a[i][j] , cout << a[i][j];
has undefined behaviour.
So do type casting once you have taken the input in this case.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.