Typedef with structure Dry Run in C

Typedef with structure 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.

Typedef with structure Program Code

#include <stdio.h>

// Using typedef to create an alias
typedef struct {
    int x;
    int y;
} Point;  // Now 'Point' is a type name

// typedef with tag name (more common)
typedef struct StudentStruct {
    int roll;
    char name[50];
    float percentage;
} Student;  // Student is alias for struct StudentStruct

// Using typedef for pointer to structure
typedef struct Node* NodePtr;
struct Node {
    int data;
    NodePtr next;  // Self-referential using typedef alias
};

int main() {
    // No need to write 'struct' keyword!
    Point p1 = {10, 20};
    Point p2;
    p2.x = 30;
    p2.y = 40;
    
    Student s1 = {101, "Amit", 85.5};
    
    printf("Point1: (%d,%d)\n", p1.x, p1.y);
    printf("Point2: (%d,%d)\n", p2.x, p2.y);
    printf("Student: %s (Roll: %d, %.2f%%)\n", s1.name, s1.roll, s1.percentage);
    
    return 0;
}

View the complete Structures programs page.

Program Console Typedef with structure Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.