Constant structure (const) Dry Run in C

Constant structure (const) 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.

Constant structure (const) Program Code

#include <stdio.h>

typedef struct {
    char name[30];
    int version;
    float threshold;
} Config;

void displayConfig(const Config *cfg) {
    // cfg->version = 10;  // ERROR: can't modify const parameter
    printf("Config: %s v%d (threshold: %.2f)\n", 
           cfg->name, cfg->version, cfg->threshold);
}

int main() {
    // Constant structure - CANNOT be modified after initialization
    const Config defaultSettings = {"System Default", 1, 75.5};
    
    // defaultSettings.version = 2;  // ERROR: can't modify const struct
    
    // Regular structure - can be modified
    Config userSettings = {"User Profile", 1, 80.0};
    
    userSettings.version = 2;  // OK - not const
    
    printf("Default (const): ");
    displayConfig(&defaultSettings);
    
    printf("User (mutable): ");
    displayConfig(&userSettings);
    
    return 0;
}

View the complete Structures programs page.

Program Console Constant structure (const) Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.