Vector Struct as function Parameter issue

I have a function readData() that takes a vector of structs as a parameter, and adds values to it. When I run the function, the code works fine, However, the values in the local vector struct from the function don't pass over to my actual vector of structs in main. What am I doing wrong?

struct babe//Struct babe
string name;
int length;
int task;
int precursor;

void readData(ifstream& input, vector<babe>& taskVec)//Function to read data from input

babe a;// new struct babe a
string name1;//variables to hold
int hey, hi, ho;
int i = 0;//counters
int j = 1;


for(i;i < j; i++)
getline(input, name1, '\n');//gets the name of the person
input >> hey >> hi >> ho;//gets the length task and precursor = name1;// sets name in babe to name1
a.length = hey;
a.task = hi;
a.precursor = ho;
taskVec.push_back(a);//adds a to taskVec
input.ignore(1000, '\n');//moves cursor to next line

j++; //J plus one
Topic archived. No new replies allowed.