Lab 9 -- More on Pointers
CPE101
Winter 2008

Due Date

Updates

Objectives

Overview

    In addition using pointers to point to different variables, you can perform arithmetic on pointers.  For example:

    	char line[30] = "computer science";
char* line_ptr;
int i;

line_ptr = line; /* set line_ptr to point to the first char of the string */

for (i=0; i<8; i++) { printf ("%c", *line_ptr); /* print out the char that line_ptr is pointing to */
line_ptr++; /* set line_ptr to point to the next char in the string */
}


    When this code runs, line_ptr is first set to point at the first element in the array line.  Each time line_ptr is incremented by 1, it will point to the next character in the string.  As the loop runs, it will print out each of the first 8 characters of the string, which is the word 'computer'.

Lab Requirements

    For this lab, you will convert the string lab (from Lab 8) to use pointer syntax instead of arrays.

    You should provide support for the following string functions:

       mystrlen
       mystrcpy
       mystrncpy
       mystrcat
       mystrncat
       mystrstr

    Here is a driver file (which you should not modify):  lab9test.c
   
    Name your file ptrStringFuncts.c

Handin

Use the handin command being sure to replace the yy with your lecture section number.

    11:59 vogon ~$ handin mhaungs Lab09-yy ptrStringFuncts.c