Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:
    1. Reads a line of characters from the console and stores them in the array pointed to by str followed by the null character '\0'.
    2. Sets *len to the number of characters read.
    3. max_len points to the size of the array str.
    4. Read only up to *max_len - 1 characters from the console.
    5. Hint: use cin.get() to read a single character at a time, and stop when you reach a ' ' newline character.
    6. Functions can only take pointers as arguments.
    7. The array subscript operator [] may not be used to access or modify the contents of an array.
    8. Reference variables may not be used.
    9. With the exception of main, all functions must be void functions.
    10. 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Prepare a constructive performance appraisal.

Answered: 1 week ago

Question

List the advantages of correct report formatting.

Answered: 1 week ago