Question
Write a C++ program that will test function described below that use pointers and dynamic memory allocation. Functions: You will write the function described below.
Write a C++ program that will test function described below that use pointers and dynamic memory allocation.
Functions:
You will write the function described below. Then you will call them from the main function, to demonstrate their correctness.
concat_array: takes two int arrays and the arrays' sizes as arguments (that's 4 arguments). It should create a new array big enough to store both arrays. Then it should copy the contents of the first array to the new array, and then copy the contents of the second array to the new array in the remaining elements, and return a pointer to the new array.
OutPut:
testing concat: Expected result: 1 2 3 4 5 6 7 8 9 0 11 22 33 44 55
Actualresult: 1 2 3 4 5 6 7 8 9 0 11 22 33 44 55
RULES:
-
DO NOT change the names of the functions!
-
DO NOT do any output from the functions (only from main)!
-
DO NOT do any input at all!
NOTES:
-
This program DOES need to be done in a Linux or Unix environment.
-
It is your responsibility to fully test your functions. They must work for ANY valid input. The main function you submit must have at least one test case for each function. However, you should test the functions over several different test cases to convince yourself that they work.
-
You do not need to use named constants for your test data (or array sizes) in this assignment, but you DO need to follow the rest of the style guidelines including function definition and comments.
-
Your program should release any dynamically allocated memory when it is finished using it.
-
you may want to include a function that displays the values of an int array on one line, separated by spaces, for displaying test arrays and results.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started