|
|
setlocale() - Time Date Function
|
Tutorials

Cpp

|
Topic |
How to set / retrieve locale using time date function in C++?
|
|
Explanation |
|
setlocale() date function is used to set / retrieve the locale settings for the
program execution. If it is null, it returns a pointer to the current localization string. Following table
lists the macros of the specified type.
| Macro |
Descrption |
| LC_ALL |
Refers all localization categories. |
| LC_COLLATE |
Affects the operation of strcoll() function. |
| LC_CTYPE |
Alters the way the character functions work. |
| LC_MONETARY |
Determines the monetary format. |
| LC_NUMERIC |
Changes the decimal point character for formatted I/O functions. |
| LC_TIME |
Determine the functioning of strftime() function. |
Syntax:
char *setlocale(int type, const char *locale);
Example:
#include <stdio.h>
#include <locale.h>
int main ()
{
struct lconv * st;
st=localeconv();
printf ("Locale is: %s\n", setlocale(LC_ALL,NULL) );
printf ("Currency symbol is: %s\n-\n",st->currency_symbol,
setlocale (LC_ALL,"French") );
return 0;
}
|
Result:
Locale is: C
Currency symbol is: ç
In the above example "setlocale()" is used to set / retrieve the locale setting of france, so that the french
currency symbol is displayed.
|
| Note |
C++ is one of the most used programming languages in the world. Also known as "C with Classes".
Hope you enjoy this tutorial. Do send your feedback or suggestions on this C++ tutorial. This is a copyright content.
|
|
|
|