Printing integers with thousands separators in Windows using C

前端 未结 2 1450
萌比男神i
萌比男神i 2021-01-16 10:38

The question is pretty self-explanatory, I suppose. I am using printf and friends (snprintf etc) to display some memory statistics that are in the millions or hundreds-of-th

2条回答
  •  逝去的感伤
    2021-01-16 11:28

    The Win32 API does provide a function that will format a number with thousands grouping (or whatever grouping is appropriate for the specified locale): GetNumberFormat() (http://msdn.microsoft.com/en-us/library/dd318110.aspx).

    Unfortunately, it's a pretty painful API to use - not nearly as simple as the apostrophe format specifier in SUS (on the other hand, you get a lot of flexibility in exchange for the complexity)

提交回复
热议问题