StrOps::Sub( StrPtr &, char, char )

Substitute instances of one character for another.

Virtual?

No

 

Class

StrOps

 

Arguments

StrPtr &string

the string on which to operate

 

target

the target character

 

replace

the character with which to replace target

Returns

void

 

Notes

This function substitutes the replace character for every instance of the target character in the input string. The substitution is performed in place.

Example

#include <stdhdrs.h>
#include <strbuf.h>
#include <strops.h>

int main( int argc, char **argv )
{
    StrBuf sb;
    sb.Set( "\tPassword" );

    StrOps::Sub( sb, 'o', '0' );
    StrOps::Sub( sb, 'a', '4' );

    StrOps::Dump( sb );

    return 0;
}

Executing the preceding code produces the following output:

P4ssw0rd