strpbrk() – String Manipulation Function
How to replace a character in C++?
manipulation function is used to replace by returning a pointer to the first character in str1 that matches any character in the “str2”. Null terminators are not included and it returns a null pointer if no matches are found.
char * strpbrk (char * str1, const char * str2 );
char str1=”Hi welcome to hscripts!”;
printf(“The String with * replacing
spaces is:: %s.n”,str1);
The String with * replacing spaces is:: Hi*welcome*to*hscripts!.
In the above example, strpbrk() manipulation function is used to replace the space in “str1” with “*”.