CS50 Week 5 Flashcards
a hexadecimal memory address is prefixes with what?
0x
What is the base number for hexadecimal, and what symbols are used?
Base 16
0-9 and A-F
What does == compare for pointers?
The memory addresses, not the content of those addresses.
This is especially important when comparing strings.
How are pointers often represented in pseudocode?
As arrows.
What is the easiest way to compare strings?
the functions strcmp( )
What are two causes of segmentation faults?
Iterating past the bounds of an array.
Dereferencing a pointer that hasn’t been initialized.
What information exists in memory before it is initialized?
Who know!? It is just a garbage value before you put something there.
In what way is an array a pointer?
An array is a pointer with a different syntax than using a *. The two are the same thing.
- c is equivalent to c[0]
- (c+i) is equivalent to c[i]
Visualize a graphical representation of memory:
text ---------------- initialized data ------------------ uninitialized data -------------------- heap | V
^ | stack ---------------------------- environmental variables
What are the four steps of compiling?
pre-processing
compiling
assembling
linking
What happens during pre-processing?
The header files are pasted to the top of the program, and constants in the body are replaced with their values.
What happens during the compiling phase?
The source code is translated into assembly language.
What happens during assembling?
The assembly language is translated into machine code.
What happens during linking?
The machine code is combined with whatever other machine code has been specified.
What is in the “text” portion of the memory diagram?
The 0s and 1s of the program.