Question: Problem 1 : Pointer - based Functions ( 2 5 points ) Write a program in which you create four functions that work with C

Problem 1: Pointer-based Functions (25 points)
Write a program in which you create four functions that work with C-style strings. These functions must use pointers in their implementation and must not use any C++ library code.
The functions to implement are:
1. length-which determines how many characters are in the string; its parameter is a pointer to the C -style string; its output value is a number representing the count of characters in the string which might be zero-note that the input string is not modified
2. indexof - which determines the index location of a character; its parameters are a pointer to the C-style string and a character which is to be searched for; its output value is a number representing the first (lowest) index of the character or -1 if the character is not found in the string-note that the input string is not modified
3. replace - which changes every occurrences of a character within the string with a different character; its parameters are a pointer to the C-style string, a character representing the character to replace, and another character representing the character that each found occurrence is changed to; the output value is a pointer to the input string (which permits easier coding for the client code)-note that the input string is modified 4. concat - which produces a new C-style string being the concatenation of two input strings; its parameters are two pointers to strings; the output value is a pointer to a newly created string which is a copy of the first string followed by a copy of the second-note that the input strings are not modified and that the client code should delete the new string before exiting the program
Write a program that tests each function and displays the results of their use.
Design, edit, run, test, and debug your program. Enter the completed C++ code here:
C++ code for the lab project:
Run the code, take a screenshot of the results, and insert the screenshot here:
Screenshot of the results:
Problem 2: Reading and Writing Text Files (25 points)
Write a program in which you read an existing text file which contains multiple lines, some of which are blank. Open an output file and write to it the non-blank lines.
Display the input and output files after the program runs to demonstrate proper results.
Design, edit, run, test, and debug your program. Enter the completed C++ code here:
C++ code for the lab project:
Problem 1 : Pointer - based Functions ( 2 5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!