CS 132 – Practice Final

 

 

Questions on this practice final are more vague and broad than most will be on the final. Most of the following are essay, whereas only a couple on the actual will be essay questions.

 

 

1.) What is a regular expression, what command in UNIX uses them, and why are they useful?

 

 

 

 

 

 

 

 

 

 

2.) Write a swap function that actually works, and show how you would use it.

 

 

 

 

 

 

 

 

 

 

 

 

 

3.) What is a memory leak? Why should they be avoided?

 

 

 

 

 

 

 

 

 

 

4.) What is a buffer overrun vulnerability and why is gets() particularly susceptible to them?

 

 

 

 

 

 

 

 

 

 

 

 

5.) What can we do instead of using gets() to avoid the problems in question 4?

 

 

 

 

 

 

 

 

 

 

 

6.) What is an advantage of using a text file over a binary file? And vice versa?

 

 

 

 

 

 

 

 

 

7.) Why is there a problem if we follow a fscanf() with a fgets()?

 

 

 

 

 

 

 

 

 

8.) What are the two ways of tracking the end of variable length data? Which do strings in C use? Which do linked lists use?

 

 

 

 

 

 

 

 

 

 

 

9.) When is it most appropriate to use insert-at-beginning, insert-at-end, or insert-someplace-in-the-middle when inserting data in a linked list?

 

 

 

 

 

 

 

 

 

 

10.) What is the difference between lifetime and scope?

 

 

 

 

 

 

 

 

 

 

11.) How does strtok() work?