Latest web development tutorials

C library functions - strxfrm ()

C standard library - <string.h> C standard library - <string.h>

description

C library functionssize_t strxfrm (char * dest, const char * src, size_t n) according to the program's current locale LC_COLLATE option to convert thefirstncharacters of the stringsrc,and to place them in the stringdest.

statement

Here is () statement strxfrm function.

size_t strxfrm(char *dest, const char *src, size_t n)

parameter

  • dest - pointer to the storage contents of the destination array, if the parameter n is 0, then it is a null pointer.
  • src - to be converted to the current locale C string.
  • n - is copied to the maximum number of characters of str1.

return value

This function returns the length of the string to be converted, not including the null terminator character.

Examples

The following example demonstrates strxfrm () function is used.

#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("字符串 |%s| 的长度是: |%d|", dest, len);
   
   return(0);
}

Let's compile and run the above program, which will result in the following:

字符串 |W3C School| 的长度是: |10|

C standard library - <string.h> C standard library - <string.h>