Accessing structure members
📖 Scenario: You are working on a simple program to store and display information about a book. You will create a structure to hold the book's title and number of pages, then access and print these details.
🎯 Goal: Build a C program that defines a struct for a book with a title and page count, assigns values to its members, and prints them.
📋 What You'll Learn
Define a
struct named Book with members title (string) and pages (integer).Create a variable of type
Book named myBook.Assign the title "C Programming" to
myBook.title.Assign the number 250 to
myBook.pages.Print the book's title and page count using
printf.💡 Why This Matters
🌍 Real World
Structures help organize related data together, like storing information about books, students, or products in a program.
💼 Career
Understanding structures is essential for C programming jobs, especially in systems programming, embedded systems, and software development where grouping data logically is important.
Progress0 / 4 steps