strxfrm() in C/C++

CC++Server Side Programming

The function strxfrm() transforms the source string to the current locale and copies the first number of characters of transformed string to the destination. It is declared in “locale.h” header file in C language.

Here is the syntax of strxfrm() in C language,

size_t strxfrm(char *destination, const char *source, size_t number)

Here,

destination − The destination pointer where the characters will be copied.

source − The string is to be transformed.

number − The number of characters to be copied.

Here is an example of strxfrm() in C language,

Example

#include <stdio.h>
#include <string.h>
int main () has {
   char s[10] = "HelloWorld";
   char d[10];
   int n;
   n = strxfrm(d, s, 5);
   printf("Length of string : %d", n);
   return(0);
}

Output

Length of string : 10

In the above program, two char type arrays are declared. One is the destination and another is source from where the transformed set of characters are copied to the destination. It will copy only “n” characters.

char s[10] = "HelloWorld";
char d[10];
int n;
n = strxfrm(d, s, 5);
raja
Published on 05-Nov-2018 12:13:55
Advertisements