Objectives:
In this lab, we will practice:
- Use C-style strings
- Review the number of bytes necessary for a C-style string (don't forget about the null character)
- Use cstring functions
- Review the pros and cons of C-style and C++ strings
Assignment:
Write a simple C++ program that does the following:
- Declares a C-style string named oldSchoolString and initializes it to "low overhead". (Calculate, in your head, how many bytes it requires.)
- Calculates (so not a hard-coded value) and displays how many bytes oldSchoolString actually requires
- Appropriately use at least 3 functions from the cstring header file
- Display a statement about the pros and cons of using C-style strings compared with C++ strings.
Submission
Submit your source code using the
handin program. For
handin, for this lab, type the following in a terminal window exactly as it appears:
handin lab11A main.cpp
To verify your submission, type the following in a terminal window:
handin lab11A
Rubric:
Points Item
------ --------------------------------------------------------------
10 Documentation
Header comment block at the beginning of each file with:
+ Your full name
+ Date(s) code was written
+ Description
Comments explaining the role of each variable and major section of code
40 Correctness
Program solves the assigned problem using methods described in program description
+ Declares and initializes a C-style string
+ Computes and displays the number of bytes needed
+ 3+ cstring functions
+ Pros and cons statement
Program compiles without errors
Program executes without crashing
Program produces the correct output
------ --------------------------------------------------------------
50 Total