jak wczytac liczbe 3,5(liczba jest podawana z przecinkiem nie z kropka)
0
1
wczytaj to jako string pozniej zamien , na . i rzutuj na float/double
2
Możesz też kombinować w ten sposób, polegający na budowaniu własnego locale:
#include <iostream>
#include <locale>
#include <fstream>
using namespace std;
class WithComma: public numpunct<char> // class for decimal numbers with comma
{
protected: char do_decimal_point() const { return ','; } // override the function that gives the decimal separator
};
int main()
{
locale myloc( locale(), // C++ default locale
new WithComma);// Own numeric facet
double n;
ifstream f("myfile.txt");
f.imbue(myloc);
while (!f.eof())
{
f >> n;
cout << n << '\n';
}
return 0;
}