C Library Function - strxfrm()
C Standard Library - <string.h>
Description
The C library function sizet strxfrm(char *dest, const char *src, sizet n) transforms the first n characters of the string src according to the LC_COLLATE category of the current locale and places them in the string dest.
Declaration
Here is the declaration for the strxfrm() function.
size_t strxfrm(char *dest, const char *src, size_t n)
Parameters
dest -- A pointer to the target array where the content is to be stored. If n is 0, it can be a null pointer.
src -- The C string to be transformed according to the current locale.
n -- The maximum number of characters to be copied to str1.
Return Value
The function returns the length of the transformed string, not including the null-terminating character.
Example
The following example demonstrates the use of the strxfrm() function.
#include <stdio.h>
#include <string.h>
int main()
{
char dest[20];
char src[20];
int len;
strcpy(src, "W3C School");
len = strxfrm(dest, src, 20);
printf("The length of string |%s| is: |%d|", dest, len);
return(0);
}
Let's compile and run the above program, which will produce the following result:
The length of string |W3C School| is: |10|