strxfrm() - String Manipulation Function

How is "strxfrm()" used in C++?


strxfrm() manipulation function transforms the characters of "str2" so that it can be used by "strcmp()" and puts the result into "str1". This function will return the length of the characters in the transformed string.


size_t strxfrm ( char * str1, const char * str2, size_t num );

Example :

#include <stdio.h>
#include <cstring.h>
int main()
char str1[20];
char str2[] = "usanetdir";
int result = strxfrm(str1, str2, 5);
str2[5] = '';
printf ("Conversion string: %s\n", str2);
printf ("Length of converted bytes: %i\n", result);
return 0;

Result :

Conversion string: usane
Length of converted bytes: 9

In the above example, this manipulation is used transform the first 5 characters of "str2", the number of bytes converted is "9".

C++ Tutorial

Ask Questions

Ask Question