R
Rosario1903
why the below goes to seg fault?
#include <iostream>
#include <vector>
using namespace std;
void f(vector<unsigned>& v)
{v[3]=4; v[4]=9;}
int main(void)
{vector <unsigned> mv;
mv[0]=1; mv[1]=2;
f(mv);
cout<<"mv[0]="<<mv[0]<<", mv[1]="<<mv[1]<<"\n";
cout<<"mv[3]="<<mv[3]<<", mv[4]="<<mv[4]<<" mv[5]="<<mv[5]<<"\n";
return 0;
}
#include <iostream>
#include <vector>
using namespace std;
void f(vector<unsigned>& v)
{v[3]=4; v[4]=9;}
int main(void)
{vector <unsigned> mv;
mv[0]=1; mv[1]=2;
f(mv);
cout<<"mv[0]="<<mv[0]<<", mv[1]="<<mv[1]<<"\n";
cout<<"mv[3]="<<mv[3]<<", mv[4]="<<mv[4]<<" mv[5]="<<mv[5]<<"\n";
return 0;
}