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

Challenge: Manipulate a pointer array - C Tutorial

From the course: Master C Language Pointers

Start my 1-month free trial

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.…

Contents