I was doing some coding and I noticed something, Usually for an array of integers if we do like this:
int x;
cin>>x;
int a[x];
for(int i=0;i<x;i++) cin>>a[i];
for(int i=0;i<x;i++) cout<<i<<" "<<a[i]<<endl;
for this input
3
11
12
13
we get the output like this
0 11
1 12
2 13
while on the other hand, If I do something with an array of strings:
cin>>query_count;
string queries[query_count+1];
for(int i=0;i<=query_count;i++) getline(cin,queries[i]);
for(int i=0;i<=query_count;i++) cout<<i<<" "<<queries[i]<<endl;
For this input
3
a
b
I am getting the output like this
0
1 a
2 b
Can someone explain what is happening!