Program Console Vignaankosh.com
Execution Panel
Console is empty.
Demonstrate string duplication (manual) 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 <stdlib.h>
#include <string.h>
char* duplicateString(const char* source) {
// Calculate length
int len = strlen(source);
// Allocate memory for new string (+1 for null terminator)
char* dest = (char*)malloc((len + 1) * sizeof(char));
if(dest == NULL) {
printf("Memory allocation failed!\n");
return NULL;
}
// Copy characters
for(int i = 0; i <= len; i++) {
dest[i] = source[i];
}
return dest;
}
int main() {
char original[] = "Dynamic String Duplication";
char* duplicate = duplicateString(original);
if(duplicate != NULL) {
printf("Original: %s\n", original);
printf("Duplicate: %s\n", duplicate);
printf("Addresses are different: %p vs %p\n", original, duplicate);
// Free allocated memory
free(duplicate);
}
return 0;
}