From the course: Master C Language Pointers

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Solution: Manipulate a pointer array

Solution: Manipulate a pointer array - C Tutorial

From the course: Master C Language Pointers

Start my 1-month free trial

Solution: Manipulate a pointer array

(upbeat music) - [Instructor] A pointer must be initialized before it's used. And one of the key lessons of this challenge was to ensure that you allocated storage for the pointers before using them, specifically here in the main function. An array of pointers, names, is declared at line 37. Pointer pointer notation is used in this solution file. At line 41, storage for five character pointers is allocated. The for loop at line 49 prompts for each item, and line 52 sends them off to the get_input function for allocation and filling. This code represents what you could do if you eschew a ray notation, which I would prefer you did. In this version of the code, a ray notation is used to store the five pointers declared at line 37. No allocation is required. So the rest of the code, again, uses a ray notation to reference the pointers at line 44 and 49. Note that the address operator is used at line 44 to ensure that the…

Contents