Created
November 19, 2017 11:55
-
-
Save rossy/1866e4f8fdd5a9a675cdc5f5cbd5d5d0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define __USE_MINGW_ANSI_STDIO 1 | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <locale.h> | |
int main() | |
{ | |
_locale_t c = _create_locale(LC_ALL, "C"); | |
_locale_t fr = _create_locale(LC_ALL, "french"); | |
printf("The decimal point separator is '%s'\n", localeconv()->decimal_point); | |
printf("%lld %jd %zd %.1f\n", 1ll, (intmax_t)1, (size_t)1, 1.5); | |
__mingw_printf("%lld %jd %zd %.1f\n", 1ll, (intmax_t)1, (size_t)1, 1.5); | |
_printf_l("%lld %jd %zd %.1f\n", c, 1ll, (intmax_t)1, (size_t)1, 1.5); | |
_printf_l("%lld %jd %zd %.1f\n", fr, 1ll, (intmax_t)1, (size_t)1, 1.5); | |
if (!setlocale(LC_ALL, "french")) { | |
printf("Can't change locale\n"); | |
return 1; | |
} | |
printf("The decimal point separator is '%s'\n", localeconv()->decimal_point); | |
printf("%lld %jd %zd %.1f\n", 1ll, (intmax_t)1, (size_t)1, 1.5); | |
__mingw_printf("%lld %jd %zd %.1f\n", 1ll, (intmax_t)1, (size_t)1, 1.5); | |
_printf_l("%lld %jd %zd %.1f\n", c, 1ll, (intmax_t)1, (size_t)1, 1.5); | |
_printf_l("%lld %jd %zd %.1f\n", fr, 1ll, (intmax_t)1, (size_t)1, 1.5); | |
} | |
// Output: | |
// The decimal point separator is '.' | |
// 1 1 1 1.5 | |
// 1 1 1 1.5 | |
// 1 jd zd 0.0 | |
// 1 jd zd 0,0 | |
// The decimal point separator is ',' | |
// 1 1 1 1,5 | |
// 1 1 1 1,5 | |
// 1 jd zd 0.0 | |
// 1 jd zd 0,0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment