0
Why there is no output?
#include <iostream> using namespace std; int main() { string arr [2] = {"12","st"}; cout << arr[2]; return 0; }
2 Answers
+ 8
That's because arr[2] doesn't exist.
Your array has a size for 2 elements.
Since array indexing starts from 0, so you can access first element/index by arr[0] and similary second one like arr[1].
Also note that compiler will give 'Index out of bound' or 'Memory access violation' (not sure which one of them) error.
+ 1
I forget about it.Thank you veru much!