strxfrm() in C/C++

CC++Server Side Programming

The function strxfrm() transforms the source string to the current locale and copies the first number of characters of transformed string to the destination. It is declared in “locale.h” header file in C language.

Here is the syntax of strxfrm() in C language,

size_t strxfrm(char *destination, const char *source, size_t number)


destination − The destination pointer where the characters will be copied.

source − The string is to be transformed.

number − The number of characters to be copied.

Here is an example of strxfrm() in C language,


#include <stdio.h>
#include <string.h>
int main () has {
   char s[10] = "HelloWorld";
   char d[10];
   int n;
   n = strxfrm(d, s, 5);
   printf("Length of string : %d", n);


Length of string : 10

In the above program, two char type arrays are declared. One is the destination and another is source from where the transformed set of characters are copied to the destination. It will copy only “n” characters.

char s[10] = "HelloWorld";
char d[10];
int n;
n = strxfrm(d, s, 5);
Updated on 26-Jun-2020 07:51:52