diff options
| author | David Faulkner <[email protected]> | 2026-08-07 23:40:47 -0500 |
|---|---|---|
| committer | David Faulkner <[email protected]> | 2026-08-07 23:40:47 -0500 |
| commit | b3e9e62599532050fc776c5e8f076915b56c2235 (patch) | |
| tree | af252346106a61b18cc6fc6fdbd32e962d096f1c /locale.c | |
Import official C23 code examples for Modern C (Jens Gustedt, 2024)HEADupstream-importmain
- Add official C source files, Makefile, c23-fallback.h, and LICENSE
- Update README.md with study mirror notice
Diffstat (limited to 'locale.c')
| -rw-r--r-- | locale.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/locale.c b/locale.c new file mode 100644 index 0000000..8e258f2 --- /dev/null +++ b/locale.c @@ -0,0 +1,22 @@ +#include <locale.h> +#include <stdio.h> + +/* You may have to unset the LANGUAGE environment variable for this to + work properly. */ + +int main(int argc, char* argv[argc+1]) { + perror("With C locale"); + if (!setlocale(LC_ALL, "")) + perror("couldn't set locale"); + else + perror("With default locale"); + if (!setlocale(LC_MESSAGES, "C")) + perror("couldn't set locale"); + else + perror("C locale, again"); + if (argv[1] && !setlocale(LC_MESSAGES, argv[1])) + perror("couldn't set locale"); + else + perror("new locale"); + printf("commandline argument was '%s'\n", argv[1]); +} |
