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.
SyntaxFollowing 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 −
This function returns the length of the transformed string that doesn't include the termination of null-character('\0').
Example 1Following 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4