I need to print a csv file with numbers. When the file is printed , I have numbers with dots, but I need them with commas.
Here an example. If I print this number in terminal using locale method, I obtain a number with comma, but in the file I have the same number but with dot. I do not understand why. How could I do?
#include <iostream>
#include <locale>
#include <string> // std::string, std::to_string
#include <fstream>
using namespace std;
int main()
{
double x = 2.87;
std::setlocale(LC_NUMERIC, "de_DE");
std::cout.imbue(std::locale(""));
std::cout << x << std::endl;
ofstream outputfile ("out.csv");
if (outputfile.is_open())
{
outputfile <<to_string(x)<<"\n\n";
}
return 0;
}
Thanks in advance.