Hello guys so this is my code. I could not use cin nor getline() so I had to use scanf. It reads all the values in as expected but after entering the last value it says:
free(): invalid pointer ./comp: line 8: 877 Aborted (core dumped) ./$BIN
Anyways, here is the code. Help would be appreciated.
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
    // n -> amount of lines of code.
    // q -> amount of queries.
    int n, q;
    cin >> n >> q;
    // Handle source code Input.
    vector<string> v(n);
    for (unsigned i = 0; i < n; ++i)
    {
        cout << "i: " << i << endl;
        scanf("%s", &v[i]);
    }
    
    return 0;
}
 
    