I'm trying to get value (all decimal number) from a text in c++. But I have a problem and I couldn't solve it
#include "pch.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
int main()
{
std::ifstream infile("C:\\thefile.txt");
float a, b;
while (infile >> a >> b)
{
// process pair (a,b)
}
std::cout << a << " " << b;
}
thefile.txt:
34.123456789 77.987654321
When I run the above code,
a = 34.1235
b = 77.9877
but I want
a = 34.123456789
b = 77.987654321
what should I do?
EDIT: I don't want to print out of a and b. I just want they get the exact values.net