C++ printf with %f but localized for the user's country

白昼怎懂夜的黑 提交于 2019-11-29 03:25:29

The radix character (i.e. '.' or ',') is defined by the current locale. The default locale (at least for Windows systems) is "C", which defines '.' as radix character.

You can set the current locale for a C/C++ program using the setlocale function.

To set the locale to the current system/user locale, you can use the following statement:

#include <locale.h>
setlocale(LC_ALL, ".OCP");

See here (cf. the examples on the linked page...) for more information about setlocale

Damian Walczak
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!