I have a file in which there are 3 space separated floats on each line. I have written a simple program to read from file and display the read input. But for some reason first value's decimal part is being discarded.
Code:
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;
int main(){
ifstream f("pointcloud.csv", f.in);
float x[100], y[100], z[100];
int i = 0;
for(std::string line; std::getline(f, line); ) //read stream line by line
{
std::istringstream in(line); //make a stream for the line itself
in >> x[i] >> y[i] >> z[i++];
}
for(int i = 0; i < 100; i++){
cout << x[i] << " " << y[i] << " " << z[i] << endl;
}
f.close();
return 0;
}
Input:
429372.16 3680107.43 76.91
429371.55 3680107.73 75.92
429371.54 3680107.65 75.93
...
Output:
429372 3680107.43 76.91
429371 3680107.73 75.92
429371 3680107.65 75.93
...
why the decimal part of all X's are missing?