1

I've a, large Qt/C++ program. It extensively uses a few old routines, which use fscanf() to input float numbers from files.

Now I want to port that program in Ubuntu. I've made a crazy discovery: it seems that fscanf() always wants commas to be decimal separators! I tested this using Qt 5.5 and Gcc 5.5.1, but probably this issue applies to all Gcc's under Ubuntu.

Instead my program assumes that the decimal separator is always dot (which is the standard on all the other compilers/systems I know).

Does anyone know how to tell the compiler that input numbers use dots as decimal separators?

MaxC
  • 11
  • 2
  • show your code. – eyllanesc Jan 03 '18 at 08:26
  • 3
    The [`std::scanf` family of functions](http://en.cppreference.com/w/cpp/io/c/fscanf) are *locale aware*. That means if you have a locale in which a comma is used for decimal separator then that's what you must use. Or change the locale for your application. Or use some other function which is not aware of the locale. – Some programmer dude Jan 03 '18 at 08:26
  • [see here](https://stackoverflow.com/questions/33323886/c-f-dot-instead-of-comma) – csabinho Jan 03 '18 at 08:28
  • Yes! you told me the exact words I needed. I successfully implemented your hint just adding the following row setlocale(LC_NUMERIC,"C"); to the code, immediately after creation of the main Window. Thanks a lot! – MaxC Jan 03 '18 at 08:59

0 Answers0