69,382
社区成员
发帖
与我相关
我的任务
分享
/* setlocale example */
#include <stdio.h>
#include <time.h>
#include <locale.h>
int main ()
{
time_t rawtime;
struct tm * timeinfo;
char buffer [80];
struct lconv * lc;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
int twice=0;
do {
printf ("Locale is: %s\n", setlocale(LC_ALL,NULL) );
strftime (buffer,80,"%c",timeinfo);
printf ("Date is: %s\n",buffer);
lc = localeconv ();
printf ("Currency symbol is: %s\n-\n",lc->currency_symbol);
setlocale (LC_ALL,"");
} while (!twice++);
return 0;
}
-----------------------------------------------
One of the possible outputs when the previous code is run is:
Locale is: CDate is: 01/15/07 13:33:47Currecy symbol is: -Locale is: English_United States.1252Date is: 1/15/07 1:33:47 PMCurrency symbol is: $-