CIS 275 Lab 2

Points: 50 Due Date: Thursday April 17, 2003

This project will involve arrays, but it will also be practice with pointers. You will use pointers to the arrays. All array references will be pointers. Do not use [] notation. No classes needed this time.

Take a character array containing a string of characters. This can be a constant or read from the input. Write a function that prints this out, character by character. It will take a pointer to the string to be printed and then it will use that pointer to print each character.

Then write another function that creates a new array using new and copy just the vowels from the source string into the new array. This function will return a string pointer. Then you will use the print function you wrote above to print the resulting string. The vowel finding function doesn't call the print function, this is done in the main().

The vowel finder function should throw an exception if there are no vowels in the string. This should be caught in main() before you attempt to print the vowels. Make sure you try a test string that has no vowels to test this.

For 5 points extra credit, write a third function that takes a character array string and a single character as an second argument. It returns either a pointer to the first place in the string that is the character or NULL.

Deliverables:

You should turn in a listing of the program along with sample output. Staple the cover sheet to that.

Notes

Start as soon as you can, pointers are quite tricky and can be confusing. Think about how you will do this so you can ask questions during lab.
ASK if you have any questions.