Before coming to Class 2, please work your way through the following material:
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Watch | Lecture | Week 2, continued | Watch the week's second lecture, with Rob Bowden filling in for David. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Read | Lecture Notes | Week 2, continued / More on Strings | Review the notes on the first part of the lecture about strings. Stop at the Arrays header. |
| Read | Resource | Custom strlen | A from-scratch implementation of the strlen function, to help illustrate how to write your own function, and give some insight into the chars that make up strings |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Read | Resource | Array Basics | A quick runthrough of array syntax basics: how to declare, read, write |
| Watch | Doug's Playlist | Arrays | Doug talks about arrays, an important data structure. |
| Follow-Along | Walkthroughs | ages | Follow David to create a program that uses an array to get the ages of everyone in a room. You can grab the pseudocode here. |
| Do | Exercise | Can You Vote? | Write a program to read through an array of peoples' ages and outputs whether or not they are old enough to vote. |
| Read | Lecture Notes | Week 2, continued / Arrays | Read through the notes on "Arrays", which will review the ages program you recently wrote. |
| Watch | Shorts | Arrays | This short will talk about when to use an array, and how to implement one. Rob talks about "pointer arrays" and malloc - don't worry about this for now. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Read | Lecture Notes | Command-Line Arguments | Read the section titled "Command-Line Arguments". We'll be using these in Problem Set 2. Stop when you get to the Cryptography header. |
| Follow-Along | Walkthrough | argv-0 | Follow David to create a program that takes command-line arguments. You can grab the pseudocode here. |
| Follow-Along | Walkthrough | argv-1 | Continue working on this program to make it print out all of the command-line arugments we get from the user. You can grab the pseudocode here. |
| Do | Exercise | Argv With Indexes | Practice accessing the command line arguments by indexing into argv |
| Do | Exercise | Previous | Use a new function called atoi() to fix a broken code example. |
| Watch | Doug's Playlist | Command-Line Arguments | Doug reviews command-line arguments in more depth. |
| Do | Exercise | Command-line Calculator | Extend the ideas you learned in Adder and argv-0 to add numbers that the user provides on the command line. |
| Follow-Along | Walkthrough | argv-2 | Return to the argv program and follow David to make it print out all of the individual characters from the command-line arugments. You can grab the pseudocode here. |
| Watch | Shorts | Command-Line Arguments | Watch this short that talks more about command-line arguments, argc, and argv. |
| Study | CS50 Study | Command-Line Arguments | If helpful, you can test and review your knowledge of command-line arguments using CS50 Study. |
| Task | Resource Type | Link | Instructions |
|---|---|---|---|
| Watch | Shorts | Global Variables | Joe introduces the concept of the global variable, which is a variable that is not limited to a local scope, like the normal "local" variables we have been using so far. |
| Watch | Doug's Playlist | Magic Numbers | Doug introduces the concept of "magic numbers", explaining why we want to avoid them and how we can do so. |
| Read | Resource | Magic Numbers | Look over an example program that eliminates its magic numbers while avoiding the danger of global variables. |