We may need to convert some C code to work in a euro number presentation
environment, and I have looked up setlocale() etc, and the decimal place
works fine, but I cant get any sense out of thousands separator. We don't
actually use it ourselves (takes up space in screens and reports), but why
doesn't it work?
All the docos I have found on HP state to do
Setlocale("LC_ALL","") to force set up
And to use an apostrophe in the format, as in "%'8.2f" to tell printf to use
the separator and decimal point from locale(), but all I get instead of a
number (12345.67) is '8.2f .
Am I barking up the wrong tree here, or doing something wrong please?
Jp
This code
#include <locale.h>
#include <math.h>
/************************************************************/
main() {
int error,status[10];
double d1=12345.67;
struct lconv *lc;
lc = localeconv();
setlocale("LC_ALL","");
printf("%'8.2f\n",d1);
setlocale(LC_ALL,"portuguese");
printf("%8.2f\n",d1);
setlocale(LC_ALL,"english");
printf("%8.2f\n",d1);
Gives this result:-
:tlocale.c
'8.2f
12345,67
12345.67
* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *
|