CS50 Lesson 4 (Memory)
We start off Lesson 4 talking about base 16, (hexadecimal), and how that relates to memory addresses. Strings are really just 'pointers' to the address of the first character in memory. The programming language need not know the length of the string, as each subsequent character is stored in order, and the end of the string is always '/0', so the program can use that to know where it ends.
The &
and *
operators are introduced. &
indicates that we're looking for an address of a variable in memory, and *
is used to grab the value of what is stored in that address. Use of malloc
(memory allocation) followed by always freeing that memory after usage with free
. The class continues talking about reading and writing from files, and the instructor recreates the cp
command for copying files using the building blocks learned in class, by taking arguments for a command at the command line to create the new file name, opening the current file, and looping through each byte to add to the new file, resulting in a duplicate file of the same value of bytes.
He closes out talking about beinga able to do some image manipulation, such as creating sepia tones, blurring an image, or highlighting edges. (Not sure why he covered this part as we didn't get into it at all.)