Problems converting float to int in C++

You never initialize memory for the vector. You’ll have to do float *vector = new float[vectorSize]; and only then fill it with values (and then delete[] vector;)

Also, why are you using an array of floats while there’s std::vector that is a better choice in your situation.

What’s more, avoid calling your array vector since there exists std::vector, and if you’ll be using using namespace std; you’ll shadow it.

Leave a Comment