Copy one structure to another Dry Run in C

Copy one structure to another is an interactive C dry run visualizer from the Structures 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.

Copy one structure to another Program Code

#include <stdio.h>
#include <string.h>

struct Vector {
    int x;
    int y;
    char label[20];
};

int main() {
    struct Vector v1 = {3, 4, "Original"};
    struct Vector v2;
    
    // Method 1: Direct assignment (member-wise copy)
    v2 = v1;
    
    // Method 2: Manual member-wise copy
    struct Vector v3;
    v3.x = v1.x;
    v3.y = v1.y;
    strcpy(v3.label, v1.label);
    
    // Modify v2 to show it's a separate copy
    v2.x = 10;
    v2.y = 20;
    strcpy(v2.label, "Modified");
    
    printf("v1: (%d, %d) - %s\n", v1.x, v1.y, v1.label);
    printf("v2: (%d, %d) - %s\n", v2.x, v2.y, v2.label);
    printf("v3: (%d, %d) - %s\n", v3.x, v3.y, v3.label);
    
    return 0;
}

View the complete Structures programs page.

Program Console Copy one structure to another Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.