I'm guessing this is the line that contains the problem:
dat[i] = data2[i];
It's because dat
is a pointer, so dat[i]
is indexing dat
as a normal array and not a vector object. To solve it, don't pass it as a pointer, pass it by reference instead:
void binary(int convert,vector <unsigned>& dat) { ... }
and call it without the address-of operator:
binary(data[i], dat);
Or keep the code as it is now, but change the line in question to dereference the pointer instead:
(*dat)[i] = data2[i];