Return structure from function Dry Run in C

Return structure from function 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.

Return structure from function Program Code

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

struct Book {
    int bookId;
    char title[100];
    float price;
};

struct Book createBook(int id, char title[], float price) {
    struct Book b;
    b.bookId = id;
    strcpy(b.title, title);
    b.price = price;
    return b;
}

int main() {
    struct Book myBook;
    
    myBook = createBook(301, "The C Programming Language", 599.50);
    
    printf("Book Details:\n");
    printf("ID: %d\n", myBook.bookId);
    printf("Title: %s\n", myBook.title);
    printf("Price: ₹%.2f\n", myBook.price);
    return 0;
}

View the complete Struct Functions Pointers programs page.

Program Console Return structure from function Topic: C Vignaankosh.com
Execution Panel
Step 0/0
Console is empty.