I used arrays in my code, and now I changed them to vector and I get these errors(its in linux):
glibc detected *** double free or corruption
glibc detected malloc memory corruption
My code is so long and I can’t paste it here, here’s how I use vector:
Declared:
vector:vector<double>x;//i didnt define anysize for vector
for inserting a value in it:
x.insert(x.begin()+i,i)
to use an element:
x.at(i)
just this.
What do you think about the problem? ?
Additionally I don’t know when I should use iterator in vector, shouldn’t I use it here? ?
TIA
You say that you didn’t define any size for the vector. That means it has size zero.
In that case, this code
is invalid for any
iother than zero.