Modify structure using pointer Dry Run in C

Modify structure using pointer is an interactive C dry run visualizer from the Struct Functions Pointers 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.

Modify structure using pointer Program Code

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

struct Laptop {
    char brand[50];
    int ram;      // in GB
    int storage;  // in GB
};

int main() {
    struct Laptop myLaptop = {"Dell", 8, 512};
    struct Laptop *ptr = &myLaptop;
    
    printf("Before Modification:\n");
    printf("Brand: %s, RAM: %dGB, Storage: %dGB\n", 
           ptr->brand, ptr->ram, ptr->storage);
    
    // Modify using pointer
    strcpy(ptr->brand, "HP");
    ptr->ram = 16;
    ptr->storage = 1024;
    
    printf("\nAfter Modification:\n");
    printf("Brand: %s, RAM: %dGB, Storage: %dGB\n", 
           ptr->brand, ptr->ram, ptr->storage);
    
    return 0;
}

View the complete Struct Functions Pointers programs page.

Program Console Modify structure using pointer Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.