C++ exam代写 cpp exam代写
Question 1: Programming (10 marks)
Part A (4 marks)
Implement a function called duplicates_def that:
• Takes an array of C-Strings, called strings1
• Takes a second array of C-Strings, called strings2
• Produces a new array of C-strings that contains all strings that occur in both string1 and string2.
• Returns the arrays of C-strings that was produced (through either the return value of the function, or a separate parameter to the function)
For example, if strings1 is the array
and strings2 is the array
It will produce and return the following array of C-strings:
Implement this function using a defensive programming paradigm. That is, your function should account for all possible inputs.
Additionally in implementing your function:
• Choose suitable parameters for the function, so that your it can be fully defensive.
• Choose appropriate types for the parameters
• Ensure that your function does not crash or seg-fault.
• You may not use any methods of the C++ STL, except for the iostream header file for reading/writing to and from standard I/O.
