From the course: Master C Language Pointers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Challenge: Manipulate a pointer array - C Tutorial
From the course: Master C Language Pointers
Challenge: Manipulate a pointer array
(gentle music) - [Instructor] Brace yourself for this challenge which involves sending an array of pointers to a function. Scary, but doable. Your specific task is to write the get input function. This function's argument is the address of a pointer shown in this prototype. It returns no value. Within the get input function, the pointer's memory is allocated. A string is read from standard input and stored at the pointer's allocated address. Ensure that any newline character is removed from the string. In the main function, an array of five pointers is declared. In a loop, each address in the pointer's array is sent off one at a time to the get input function for allocating and filling. The main function then outputs the five strings. Here's a sample run of my solution to this challenge, where I'm typing in five names. And the result is output one at a time. This exercise could take 30 minutes or more to complete.…
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)
Understanding pointers to pointers4m 32s
-
(Locked)
Sending a pointer to a function3m 36s
-
(Locked)
Sorting pointers2m 6s
-
(Locked)
Managing memory3m 56s
-
(Locked)
Creating pointers to functions2m 30s
-
(Locked)
Challenge: Manipulate a pointer array1m 18s
-
(Locked)
Solution: Manipulate a pointer array3m 20s
-
(Locked)