I have to input an int n, and read n lines in a string array. But when I test my code, for example, I put 3, it will read only 2. I found that I should use vectors, but why, is there any way easier than vectors to read n lines ?
Example code:
#include <iostream>
using namespace std;
int main() {
int n;
cin >> n;
string niz[n];
for (int t1 = 0; t1 < n; t1++) {
getline(cin, niz[t1]); }
for (int t2 = 0; t2 < n; t2++) {
cout << niz[t2] << endl; }
}