Program Console Vignaankosh.com
Execution Panel
Console is empty.
Replace a substring with another string is an interactive C dry run visualizer from the String Functions 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.
#include <stdio.h>
#include <string.h>
int main() {
char str[100] = "I like Java";
char old_substr[] = "Java";
char new_substr[] = "C Programming";
char result[100];
printf("Original: %s\n", str);
char *pos = strstr(str, old_substr);
if(pos != NULL) {
int index = pos - str;
int len_old = strlen(old_substr);
int len_new = strlen(new_substr);
// Copy part before old substring
strncpy(result, str, index);
result[index] = '\0';
// Append new substring
strcat(result, new_substr);
// Append remaining part after old substring
strcat(result, pos + len_old);
printf("After replacement: %s\n", result);
} else {
printf("Substring not found!\n");
}
return 0;
}