From the course: Advanced C Programming: Optimize Performance and Efficiency
Unlock the full course today
Join today to access over 24,500 courses taught by industry experts.
Send a structure to a function - C Tutorial
From the course: Advanced C Programming: Optimize Performance and Efficiency
Send a structure to a function
- [Instructor] Of all the variables you can pass to a function, a structure causes the most angst. Yep, even more than passing a pointer argument. Pointers are sinchy when compared with structures. To put a structure to work you must do two things. First, you need to define the structure and its members. Second, you need to declare a variable of that particular structure type. Both of these at elements come into play when using a structure as a function's argument. Open exercise file four seven structfunct1. The function showStruct is prototyped at line four. It returns nothing, but it accepts as an argument a person structure. Inside the main function, the person structure is defined, and a variable author of that structure type is declared. The structure is filled. Then at line 19, the showStruct function is called with the structure variable author as its argument. Inside the showStruct function at line 24 the structure's…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Sort an array6m 39s
-
(Locked)
Challenge: Sort a string24s
-
(Locked)
Solution: Sort a string1m 28s
-
(Locked)
Work with arrays and functions3m 21s
-
(Locked)
Challenge: An array-modification function24s
-
(Locked)
Solution: An array-modification function1m 16s
-
(Locked)
Send a structure to a function4m
-
(Locked)
Challenge: Create a structure function27s
-
(Locked)
Solution: Create a structure function1m 20s
-
(Locked)
Build an array of structures3m 36s
-
(Locked)
Challenge: Sort an array of structures32s
-
(Locked)
Solution: Sort an array of structures1m 7s
-
(Locked)
-
-