R17 Replace characters in string (Recursion) Dry Run in C

R17 Replace characters in string (Recursion) is an interactive C dry run visualizer from the Recursion programs section. Study the source code, then use the execution controls to follow each step, variable update, highlighted line, and console output.

This page provides a browser-based dry run with source-code highlighting, auto-scroll, voice narration controls, and execution output for learning the program step by step.

R17 Replace characters in string (Recursion) Program Code

#include <stdio.h>

void replaceChar(char str[], char oldChar, char newChar, int index) {
    if(str[index] == '\0') {
        return;
    }

    char currentChar = str[index];

    if(currentChar == oldChar) {
        str[index] = newChar;
    }
    replaceChar(str, oldChar, newChar, index + 1);
}

int main() {
    char text[] = "banana";
    printf("Original: %s\n", text);
    replaceChar(text, 'a', 'o', 0);
    printf("After replace: %s\n", text);
    return 0;
}

View the complete Recursion programs page.

Program Console R17 Replace characters in string (Recursion) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.