Question:
In the following code, how do I get the address of the first character of str in the function discard?
discard(string *name){ //..}int main(){ string str; cin >> str; discard(str); return(0);}
Answer:
It’s simple: &str[0] returns the address of the first character of the string object.