codescracker


c

C setlocale()



« Previous Function Next Function »


setlocale()

The setlocale() function allows certain parameters that are sensitive to the geopolitical environment of a program's execution to be queried or set. If locale is null, setlocale() returns a pointer to the current localization string. Otherwise, setlocale() attempts to use the string specified by locale to set the locale parameters as specified by type. To specify the standard C locale, use the string "C". To specify the native environment, use the null string "". Refer to your compiler's documentation for the localization strings that it supports.

At the time of the call, type must be one of the following macros (defined in <locale.h>) :
LC_ALL
LC_COLLATE
LC_CTYPE
LC_MONETARY
LC_NUMERIC
LC_TIME

LC_ALL refers to all localization categories. LC_COLLATE affects the operation of the 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 input/output functions. Finally, LC_TIME determines the behaviour of the strftime() function.

The setlocale() function returns a pointer to a string associated with the type parameter.

setlocale() Syntax

Following is the syntax of the setlocale() function :

#include<locale.h>
char *setlocale(int type, const char *locale);

setlocale() Example

Following program displays the current locale setting :

#include<locale.h>
#include<stdio.h>
#include<conio.h>
void main()
{
	clrscr();
	
	printf(setlocale(LC_ALL, ""));
	
	getch();
}

« Previous Function Next Function »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test