Question 7
Back to Exercise
A function is declared void edit(char *s);. What happens when you call edit(msg) with const char *msg?
- A Nothing special
- B The const qualifier is discarded; the compiler warns, because edit() could write to read-only data Correct
- C msg is copied
- D It is converted safely
Correct Answer: Option B
Adding const is implicit and safe (char * → const char *); removing it is not. The fix is to make edit() take const char * if it does not write, or pass a modifiable copy.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!