Guest_imported
New member
- Jan 1, 1970
- 0
I need to write a function that will search for a character in a string and replace all occurances of it with another character
Thanks in advance
Thanks in advance
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
char A[10];
.
.
.
for(int x = 0; x<10; ++x)
{
char Z = A[x];
.
.
.
}
// before--> character to replace
// after --> character replacing
// pstring --> string sampled
char* replace(char before, char after, char *pstring) {
for(i=0;i<strlen(pstring);i++) {
if(pstring[i] == before)
pstring[i] = after;
}
return pstring;
}