In Class Week10

  1. Copy the files for today's class into your week10 directory, then change into that directory and check the contents:
         % cd ~/cs21/week10
         % cp ~newhall/public/cs21/week10/substring.c  .
         % cp ~newhall/public/cs21/week10/invertname.c  .
         % ls
    

  2. We will start with copystr.c from last time.

  3. Open up substring.c and implement and test the GetALine function.

  4. Once you have that working, implement and test the SubString function.

    Run your program with valgrind to see if you have any memory leaks, or any other memory access errors:

    	% gccx -o substring substring.c 
    	% valgrind --leak-check=yes ./substring
    
    We will likely not get to these in class, but here are some other things you may want to try out to get more practice with strings:

  5. Open up invertname.c, copy your implementation of GetString from the substring.c file into this file. Implement and test the InvertName function. Again, run valgrind to test for memory access errors.

  6. open up substring.c and implement the GetString function (start by copying the contents of GetALine and change it). Replace the call to GetALine with GetString in the main program, and test your function.