Objective:
Program with c-strings
Preparation:
Review Chapters 9 and 10 from Starting Out with C++ by Gattis
Assignment:
- Place your code in a file named LlllFfffLab01.cpp where Llll is the first four letters of your last name and Ffff is the first four letters of your first name.
- Write a function named getString that has a local char array of 80 elements. The function should ask the user to enter a sentence, and store
the sentence in the array. Then the function should dynamically allocate a char array just large enough to hold the sentence, plus the null character. It should
copy the sentence into the dynamically allocated array, and then return a pointer
to that dynamically allocated array.
- Write a function called countWords as described in Programming Challenge 3 on page 594 of the text. Don't demonstrate
it in a program at this point. Don't do the optional exercise.
- Write a driver program that has the user try getString with countWords. It should repeat as long as the user wants to keep trying the functions.
- Verify your program works correctly.
- Submit your source code file to
ude.wons@nosneros.htrag. Due at 8:00 a.m. on 7 January.