Question: I'm having difficulty with pointers and could use an example of the following function: (The restrictions that are making this so hard for me are
I'm having difficulty with pointers and could use an example of the following function: (The restrictions that are making this so hard for me are in bold after the function description)
- void read_string(char *str, const int *max_len, int *len) - does the following:
- Reads a line of characters from the console and stores them in the array pointed to by str followed by the null character '\0'.
- Sets *len to the number of characters read.
- max_len points to the size of the array str.
- Read only up to *max_len - 1 characters from the console.
- Hint: use cin.get() to read a single character at a time, and stop when you reach a ' ' newline character.
- Functions can only take pointers as arguments.
- The array subscript operator [] may not be used to access or modify the contents of an array.
- Reference variables may not be used.
- With the exception of main, all functions must be void functions.
- The C++ string class can not be used to store plaintext, keywords, or ciphertext. Instead use arrays of characters.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
