Join Dan Gookin for an in-depth discussion in this video Solution: Create a pointer array, part of C: Data Structures, Pointers, and File Systems.
(upbeat music) … - [Instructor] Here is my solution to the challenge … which is just one way to accomplish the task. … Your code need not be identical to what you see here. … I named my character pointer array fruit at line seven. … It's an array of 10 memory locations … that reference character storage. … At line eight, the buffer storage space … is used for string input. … The first for loop at line 11 fetches input, … creates buffers, and assigns those buffer addresses … to the fruit array elements. … First at lines 14 and 15, … input is fetched and stored in the buffer array. … At line 18 storage is allocated … for the fruit array element x, … based on the input string's length, … plus one for the null character. … I hope you didn't forget this … plus one part of the allocation. … The if statements handle the condition … when memory isn't available, … otherwise the address of the string input … is copied into a element of the fruit array at line 26. … This loop repeats for all 10 elements in the fruit array. …
- Working with arrays
- Building a structure
- Creating an array of structures
- Testing characters
- Working with strings in C
- Using pointers to manipulate data
- Manipulating files
- Using command-line arguments
- Working with time functions
Skill Level Intermediate
1. Arrays and Structures
2. Characters and Strings
4. Files and the Operating System
5. The Interesting and Extraordinary
Next steps1m 52s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.