0
#include <qapplication.h>
#include <qmainwindow.h>
#include "mainwindow.hpp"
#include "../RegisterOfErrors.hpp"
#include <clocale>
extern std::string* Error::DescriptionOfErrors;
int main (int argc, char *argv[])
{
std::locale::global(std::locale("en_US"));
setlocale(LC_ALL, "en_US");
FILE *conf = fopen("dupa.txt", "r");
float dupa;
fscanf(conf, "%f", &dupa);
printf("%f\n", dupa);
Error::setDescriptionOfErrors();
QApplication app(argc, argv);
MainWindow window;
window.show();
return app.exec();
}
我的默認語言環境是「es_ES」,所以「,」是小數點。 這是我的代碼。在文件「dupa.txt」是一個數字「1.0344」,它的工作正常。然而,在代碼中,我使用的是fann庫,它在g ++中通過「-ldoublefann」鏈接,並從文件中讀取一些數據,而在這個庫中只能使用「,」。看起來setlocale()在鏈接庫中不起作用
爲什麼有人會低估這個問題? – 2012-08-02 09:11:11