
- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <complex.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <fenv.h>
- C Library - <float.h>
- C Library - <inttypes.h>
- C Library - <iso646.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdalign.h>
- C Library - <stdarg.h>
- C Library - <stdbool.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <tgmath.h>
- C Library - <time.h>
- C Library - <wctype.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
C library - strxfrm() function
The C library strxfrm() function can be used to transform the first characters from the source string into current locale and place them in the destination string.
In Computer System, locale is a set of information that present the specific region or culture based on conventions and settings.
Syntax
Following is the syntax of the C library strxfrm() function −
size_t strxfrm(char *dest, const char *src, size_t n)
Parameters
This function accepts the following parameters −
- dest − This is the pointer to the destination array where the content is to be copied. It can be a null pointer if the parameter for n is zero.
- src − This is the C string to be transformed into current locale.
- n − The maximum number of characters to be copied to str1.
Return Value
This function returns the length of the transformed string that doesn't include the termination of null-character('\0').
Example 1
Following is the C library program that demonstrates the usage of strxfrm() function.
#include <stdio.h> #include <string.h> int main () { char dest[20]; char src[20]; int len; strcpy(src, "Tutorials Point"); len = strxfrm(dest, src, 20); printf("Length of string |%s| is: |%d|", dest, len); return(0); }
Output
On execution of above code, we get the following result −
Length of string |Tutorials Point| is: |15|
Example 2
In this example, we illustrate the result of applying locale-specific transformation using strxfrm() function.
#include <stdio.h> #include <string.h> int main() { // source string into current locale char str2[] = "Delhi to Hyderabad"; // declare the empty character array char str1[30]; printf("%lu\n", strxfrm(str1, str2, 4)); printf("%s\n", str1); printf("%s\n", str2); return 0; }
Output
On execution of above code, we get the following result −
18 Delh Delhi to Hyderabad