I keep getting this seg fault but I have no idea where it came from. Sorry I'm still new to coding.
#include <iostream>
#include <vector>
using namespace std;
vector<int> map(vector<int> v, vector<int>::iterator i, vector<int> result) { //set i = v.begin() in main
if (i==v.end()) {
return result;
} else {
result.push_back((*i)*(*i));
i++;
map(v,i,result);
}
}
int main() {
vector<int> v;
vector<int> result;
for (int i=0;i<20;i++) {
v.push_back(i);
}
vector<int>::iterator it=v.begin();
result=map(v,it,result);
}
And apparently, I need to add more word because my question is mostly code.