strxfrm() in C/C++
strxfrm() is a C/C++ Library function. It is used to transform the characters of the source string into the current locale and place them in the destination string. It is defined in the <locale.h> header file in C. strxfrm() function performs transformation in such a way that the result of strcmp on two strings is the same as a result of strcoll on two original strings.
For example, str1 and str2 are two strings. Similarly, num1 and num2 are two strings formed by transforming str1 and str2 respectively using the strxfrm function. Here, calling strcmp(num1,num2) is similar as calling as strcoll(str1,str2).
size_t strxfrm(char *str1, const char *str2, size_t num);
- str1: It is the string that receives num characters of the transformed string.
- str2: It is the string that is to be transformed.
- num: It is the maximum number of characters to be copied into str1.
Return Value: It returns the number of characters transformed( excluding the terminating null character ‘\0’).
Length of string geeksforge@ is: 13
Note: In this example, the spaces will be counted too.
Length of string hello geeksforgeeks9 is: 20
Example in C++:
19 HellL Hello geeksforgeeks
This article is contributed by Shivani Baghel. If you like GeeksforGeeks and would like to contribute, you can also write an article using write.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks. Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.