Hello,
I read the content of a file into two vectors in this way:
ifstream file1;
std::string line1;
std::vector x1, y1;
file1.open(argv[1]);
while (std::getline(file1, line1))
{
double x = 0., y = 0.;
sscanf (line1.c_str(), “%lf %le\n”, &x, &y);
printf("%.12lf %.17le\n", x, y); //print on screen
x1.push_back(x); //fill vectors
y1.push_back(y);
}
file1.close();
When I print them on screen I can specify the format I want so as they are seen exactly as they are in the file;
but when I use “push_back” to fill the vectors I loose the original format and x1 and y1 are approximated in a way that is not useful for my subsequent calculations.
How can I pass the original format to x1 and y1?
Thanks in advance!
Elena