Reference no: EM132200332
Write functions and function prototypes for the following:
char* copy(char* destination, const char* source, size_t num)
Copy the first num characters of a string from the address specified by source to that specified by destination. Note that source and destination are both pointers. Return a pointer to the start of the copied string.
char* reverseCopy(char* destination, const char* source, size_t num)
Copy the first num characters of a string from the address specified by source to that specified by destination, reversing the order of the characters. Return a pointer to the start of the copied string.
char* caseChangeCopy(char* destination, const char* source, size_t num)
Copy the first num characters of a string in which the case of each lowercase character is shifted to uppercase (and uppercase to lowercase), from the address specified by source to that specified by destination. Return a pointer to the start of the copied string.
You can use the character functions found in the C standard library header file <cctype> to determine whether a character is an uppercase or lowercase letter, and to convert letters from one case to the other.
char* replaceCopy(char* destination, const char* source, char target, char replace, size_t num)
Copy the first num characters of a string in which each instance of a "target" character is replaced by the "replace" character, from the address specified by source to that specified by destination. Return a pointer to the start of the copied string.
void read(char* destination, int n)
Read a string of characters entered by the user at the keyboard with a length no longer than n characters (including the null character at the end of the C string) into an address specified by destination. The user should be able to type a space or tab as part of the string.
The getline() method of the istream class in the header file <iostream> can be used to read a string that contains spaces or tabs into an array of char.
Feel free to use the existing C string manipulation functions in the C standard library header file <cstring> when coding the functions required for this assignment.