CS 31: Weekly Lab: Week 3

  1. Strings in C
  2. Pointers
  3. Parts of memory

Start up a terminal and ssh into your CS machine:
ssh -Y you@your_machine.cs.swarthmore.edu
Once remotely connected to cs, you can start other xterms on our system by: xterm &

Then create a week03 subdirectory in your weeklylab subdirectory and copy over some files (the ls and pwd commands just let you see where you are in the directory structure):

    cd cs31/weeklylab		
    pwd
    mkdir week03
    ls
    cd week03
    pwd
    cp ~newhall/public/cs31/week03/* .
    ls

Strings and Pointers in C

We are going to take a closer look at strings in C, at some C string library functions, at dynamic memory allocation, and at manipulating string data. Start by opening up teststrs.c:
vim teststrs.c

My C language references, has links to documentation on "Pointers in C", "Strings in C", and "Chars in C", that describe strings, dynamic memory allocation, and pointers in more detail. Some of this content, like pass by reference, we will cover next week.

Here is some information on reading man pages.

Parts of a program memory

When the operating system creates a process, the process has its own address space (its memory space). Everything the process can touch (instructions, data) are located at some address in its memory.

We are going to examine a C program that examines where different kinds of data are in a process' memory.

Open up memparts.c in vim:

vim memparts.c