strreplace()
Replaces parts of a string with another string.
Synopsis
int strreplace( string &source, string search, string replace);
Parameters
Parameter | Description |
---|---|
source | String to search in |
search | String to replace |
replace | Replacement string |
Return value
This function returns the number of replacements. If parameters are missing or incorrect, -1 is returned.
Errors
Missing or incorrect arguments
Description
Finds every occurrence of search in source and replaces it with replace. This modifies the source string.
Example
Replaces "twenty"; in the source string with "thirty";. Thus, the source string "one hundred and twenty"; becomes "one hundred and thirty";.
main()
{
string source;
source="one hundred and twenty";
strreplace(source, "twenty", "thirty");
}
Assignment
Strings
Availability
CTRL