CS50 Week 3 Flashcards
What happens if you try to access an element beyond the bounds of an array?
A segmentation fault
What function will convert a char to a value?
atoi(s)
What is a simple but effective debugging technique?
printf()
What is the clang argument that allows for gdb debugging?
-ggdb3
After compiling, how do you open GDP?
gdb debug
where debug is the name of the program being debugged.
What is a breakpoint in gdb?
A point at which the program pauses executing
Where is a convenient place to put the first breakpoint?
main()
How do you step line by line through your code in gdb?
next
How do you reenter the last command you typed?
hit enter with no command.
How do you start your program running from within gdb?
run
How do you check the value of a variable at the point that you are in the code, while within gdb?
print i
where i is the name of the variable
How do you display the code before and after your current position?
list
How do you move execution by execution within a function call, using gdb? This is distinct from the command “next”
step
step will be distinct from next only if you are at a function call, in which case it will follow the function instead of going to the next line of code in the sequence.
How do you set a breakpoint in gdb
break functionName
What is a linear algorithm?
An algorithm of n complexity.
It will execute n times where n is the size of the input.