Create structure inside function and return Dry Run in C

Create structure inside function and return 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.

Create structure inside function and return Program Code

#include <stdio.h>

struct Point {
    int x;
    int y;
};

struct Point createPoint(int x, int y) {
    struct Point p = {x, y};
    return p;
}

int main() {
    struct Point p1 = createPoint(10, 20);
    struct Point p2 = createPoint(30, 40);
    
    printf("Point 1: (%d, %d)\n", p1.x, p1.y);
    printf("Point 2: (%d, %d)\n", p2.x, p2.y);
    return 0;
}

View the complete Struct Functions Pointers programs page.

Program Console Create structure inside function and return Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.