Javatpoint Logo
Javatpoint Logo

Strxfrm() Function in C/C++

In this article, we will discuss the strxfrm() function in C/C++ with its syntax and examples.

What is strxfrm() function?

The strxfrm() function is a function in the C/C++ Library. It is used to insert the characters from the source string into the destination string after transforming them into the current locale. It is defined in the C header file <locale.h>. The function strxfrm() transforms data so that the output of strcmp on two strings is equal to the output of strcoll on the same pair of original strings.

For instance, let us take two strings: str1 and str2. In a similar vein, num1 and num2 are two strings created by applying the strxfrm function to convert str1 and str2. In this case, calling the strcmp(num1,num2) is comparable to calling strcoll(str1,str2).


It has the following syntax:

Defining parameters:


It is the string that is given the modified string's num characters.


The string is what has to be changed.


It is the most characters that can be copied into str1.

Value Returned:

Aside from the final null character, "\0", the amount of changed characters is returned.


Let us take an example to illustrate the strxfrm() function in C.





Transformed string: javatpoint
Length of transformed string: 11

Example 2:

Let us take another example to illustrate the strxfrm() function in C.


hello javatpoint



Transformed string: hello javatpoint
Length of transformed string (including spaces): 21

Example 3:

Let us take another example to illustrate the strxfrm() function in C++.


Original string: Hello javatpoint
Length of transformed string: 17
Transformed string: Hello javatpoint
Original string after transformation: Hello javatpoint

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA