home blog portfolio Ian Fisher

Week 1: Course introduction

Lecture notes

In-class exercises

  1. Create a file called hello.c on the remote server. We'll write a small "Hello, world!" program, and compile and run it.
  2. Do ls /usr/share/cs644/code on the remote server to see the course's source code.
  3. Notice that each of you has a directory under /home/shared. (Try running ls /home/shared with --color=never if you can't read the output.) Pick one of your classmates and create a file with a greeting in it.
  4. Linux commands and C library functions are documented in man pages. We'll take a look at man ls and man strchr.
  5. A brief run-down of some useful tools: bat, rg, fd, fzf, tldr

Homework exercises

  1. (★) What is the size_t type for in C?
  2. (★) True or false: Semicolons are optional in C.
  3. (★★) Start thinking about what language you want to use for the final project, and whether you want to follow the main track or work on your own project. (See syllabus for details.)
  4. (★★) Does this program have a bug? Why or why not?
  5. (★★) Take a look at this C function from the Python source code. Try to understand what it does and how it works. (Bonus: Can you explain how the second function in the file works?)
  6. (★★) Write a C program, redact.c, that takes a string argument and prints out the string with all digits replaced by the character 'X'. (Hint: Some standard library functions might come in handy.)
  7. (★★★) Research the concept of the stack and the heap for memory allocation. (Not to be confused with the data structures of the same name.) When do you use one versus the other? How do I know if a value in a C program is allocated on the stack or the heap?
  8. (★★★) What is the memory representation of strings (char*) in C? What is an alternate representation? What are the advantages and disadvantages of each?