Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
C++ Tutorial
C++ Language Tutorial - Object Oriented Programing - OOPs History of C++
C++ Language Tutorial - Object Oriented Programing - OOPs Structure of C++
C++ Language Tutorial - Object Oriented Programing - OOPs C++ Datatypes
C++ Language Tutorial - Object Oriented Programing - OOPs Variables
C++ Language Tutorial - Object Oriented Programing - OOPs Constants
C++ Language Tutorial - Object Oriented Programing - OOPs Operators
C++ Language Tutorial - Object Oriented Programing - OOPs Control Structures
C++ Language Tutorial - Object Oriented Programing - OOPs Arrays
C++ Language Tutorial - Object Oriented Programing - OOPs Functions
C++ Language Tutorial - Object Oriented Programing - OOPs Class
C++ Language Tutorial - Object Oriented Programing - OOPs Predefined Functions
C++ Language Tutorial - Object Oriented Programing - OOPs I/O Functions
C++ Language Tutorial - Object Oriented Programing - OOPs String, Character Functions
C++ Language Tutorial - Object Oriented Programing - OOPs Mathematical Functions
C++ Language Tutorial - Object Oriented Programing - OOPs Time Date Functions
C++ Language Tutorial - Object Oriented Programing - OOPs Dynamic Allocation
C++ Language Tutorial - Object Oriented Programing - OOPs Utility Functions
C++ Language Tutorial - Object Oriented Programing - OOPs OOP's Concept
C++ Language Tutorial - Object Oriented Programing - OOPs Special Topics
C++ Language Tutorial - Object Oriented Programing - OOPs Type casting
C++ Language Tutorial - Object Oriented Programing - OOPs Feedback
C++ Language Tutorial - Object Oriented Programing - OOPs Ask Your Doubts
 




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.

Other Links

web hosting