CS 122 - Computer Science II
Assignment 6
Parameter Passing with Pointers
String Functions
Write the following string functions and a driver program to test them. These could be written as one program or several separate programs but it would be best to write them one at a time and test each one before going on to the next. Check for error conditions that might arrise in each procedure and decide on an approach for dealing with them.

  1. Write a procedure that will read characters from the keyboard until a new line character (Enter) is typed. Store the line of text into an array of characters whose address is passed to the procedure. Do not store the new line character. Add a null character to the end of the character array.

    Procedure heading: void ReadString(char *str)

  2. Write a procedure that will copy one array of characters to another array. Accept the addresses of two character arrays as parameters and use these to copy from the second string to the first string until the NULL character has been copied.

    Sample calls:


  3. Write a procedure that will append one array of characters to the end of another. Accept the addresses of two character arrays as parameters and use these to copy from the second string to the end of the first string.

  4. Write a procedure that will take the first N characters from a one string and return them in another. Do not change the first string. Sample calls:

  5. Write a procedure that will delete the first N characters from a string. Sample calls: