Concatenate strings using function Dry Run in C

Concatenate strings using function is an interactive C dry run visualizer from the 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.

Concatenate strings using function Program Code

#include <stdio.h>

void concatenate(char dest[], char src[]) {
    // Find end of destination string
    int i = 0;
    while(dest[i] != '\0') {
        i++;
    }
    
    // Copy source string to destination
    int j = 0;
    while(src[j] != '\0') {
        dest[i] = src[j];
        i++;
        j++;
    }
    
    dest[i] = '\0';  // Add null terminator
}

int main() {
    char str1[100] = "Hello, ";
    char str2[] = "World!";
    
    printf("Before: str1 = \"%s\"\n", str1);
    printf("str2 = \"%s\"\n", str2);
    
    concatenate(str1, str2);
    
    printf("After concatenation: \"%s\"\n", str1);
    return 0;
}

View the complete Functions programs page.

Program Console Concatenate strings using function Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.