Lab 5
String Functions
Announcements
We will have a simple 5 minutes’ quiz at the beginning of the lab on Blackboard. Please sign in to your Blackboard account and finish the quiz individually. Most of your time should be focussed on finishing the lab activity questions.
You must work with a single partner, in a group of 2. You must take turns being the “designated driver” and the “non-driver”. (If there are an odd-number of students in the class, your TA will make an adjustment.)
Pre-lab reading material
Go through the link here to learn about some common string functions.
Steps You Need to Do
***Download the file given at the bottom of the page and start editing.***
Complete execution of the program should result in the following output. User input is marked in bold.
Please enter a lower-case string (max length = 80):
all generalizations are false
Length of your input is: 29
Please enter a character that you want to find in the input string:
z
Character [z] is found.
Please enter a word that you want to find in the input string:
are
Word [are] is found.
First word in the input string is all.
Second word in the input string is generalizations.
Third word in the input string is are.
Stage 0 (0.5 points)
----------------
- Prompt the user for a string.
- Display the length of the string.
- You can assume the max length of input string (char array) is 81.
Sample Output
Please enter a lower-case string (max length = 80):
all generalizations are false
The length of your input is : 29
Stage 1 (0.5 points)
-----------------
- Prompt the user for a character.
- Search for the character in the string (string entered by user in stage 1).
Sample output:
Please enter a character that you want to find in the input string:
z
Character [z] is found
Stage 2 : (1 point)
-----------------
- Prompt the user for a new word.
- Search the string (string entered by user in stage 0) for the word.
Sample output:
Please enter a word that you want to find in the input string:
are
Word [are] is found
Stage 3 : Extra Credit (1 point)
-----------------
- Separate out the first three words.
- Store them in given char arrays namely first, second and third.
Sample output:
First word in the input string is all.
Second word in the input string is generalizations.
Third word in the input string is are.