While I was testing someting, I have created a vector of type float, and put the values 1/i into that vector;however, while reading the values, the output is printed as integers and not as float.
#include <stdio.h>
#include <vector>
#include <iterator>
int main(int argc, char const *argv[])
{
std::vector<float> testVec;
for (int i = 1; i < 5; ++i)
{
float v = 1/i;
testVec.push_back(v);
}
std::vector< float >::iterator it = testVec.begin();
for (; it!=testVec.end(); ++it)
{
printf("The value of the iterator: %f, *it);
}
return 0;
}
So, what is the problem with this ? Is it related with the iterator ? I mean I have not much experienced with them.