change_char()

change_char()#

change_char() replaces all occurrences of a specified character in a string with another character and returns the count of replacements.

Prototype

int change_char(
    char *s,    /* Input string to modify */
    char old_c, /* Character to be replaced */
    char new_c  /* Replacement character */
);

Parameters

Key

Type

Description

s

char *

Pointer to the input string to be modified.

old_c

char

Character in the string to be replaced.

new_c

char

Character to replace occurrences of old_c.


Return Value

Returns the number of characters replaced in the string.

Notes

The function modifies the input string in place. Ensure that s is a valid, mutable string.

Prototype

// Not applicable in JS

Prototype

# Not applicable in Python
Examples
// TODO C examples
// TODO JS examples
# TODO Python examples