I don't have any experience with file handling so it must seem like a silly question but I have a big vector and I want to store it into a text file. I have written the following piece of code for it:
std::vector<double> finalOutput; //vector which i am storing in file
std::ofstream outputFile;
outputFile.open("Output.txt");
for (auto& t : finalOutput)
outputFile << t << '\n';
outputFile.close();
The values in the vector are something like 26.1714237331405, 26.7561856347912, 25.2838784640364 but when i check the file it is getting stored like 26.1714, 26.7562, 25.2839.
I want to store all the digits after the decimal point and not just 4 digits after decimal point. How can I do that?
P.S: I tried to typecast it by writing it as follows but that didn't work.
outputFile << (long double) t << '\n';