Created
July 16, 2018 18:59
-
-
Save geoghegan/64c00f9c42a45986579a15f3f20a3926 to your computer and use it in GitHub Desktop.
Commas in C Numerals
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
#include <stdio.h> | |
#include <locale.h> | |
int main() | |
{ | |
/* | |
This will print out as 999,999,999 | |
The magic is in the %'d but you need the locale set first | |
*/ | |
setlocale(LC_NUMERIC, ""); | |
printf("%'d\n", 999999999); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment