From the course: Complete Guide to C Programming Foundations
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Challenge: Allocating structures - C Tutorial
From the course: Complete Guide to C Programming Foundations
Challenge: Allocating structures
(upbeat music) - [Instructor] Your challenge is to create an array of structure pointers. Each structure contains two members: an integer and a character. The array contains 26 elements, each a pointer to a structure. Allocate storage for each of the 26 structures in the array. After successfully allocating memory, assign the structure's members. For the integer member, assign values 0 through 25. For the character member, assign letters A through Z. As examples, the first allocated structure has integer value 0 and character value A. The last structure has integer value 25 and character value Z. Once allocated and assigned, output the data stored in each structure. After output, ensure that you release memory assigned to each structure. I have provided a source code skeleton you can use to get started. It's available in the exercise files. This challenge should take around 15 minutes to complete.
Contents
-
-
-
-
-
-
-
-
-
-
Understanding pointers3m 23s
-
(Locked)
Using pointers to manipulate data2m 53s
-
(Locked)
Doing pointer math3m 10s
-
(Locked)
Comparing arrays and pointers5m 5s
-
(Locked)
Challenge: Output a string57s
-
(Locked)
Solution: Output a string2m 44s
-
(Locked)
Allocating storage3m 42s
-
(Locked)
Working with a pointer array4m
-
(Locked)
Using pointers in structures3m 8s
-
(Locked)
Challenge: Allocating structures1m 3s
-
(Locked)
Solution: Allocating structures3m 34s
-
(Locked)
Passing pointers to functions2m 23s
-
(Locked)
Returning pointers from a function2m 31s
-
Chapter challenge: Processing input1m 26s
-
(Locked)
Chapter solution: Processing input3m 14s
-
-
-
-