Read a full line with getline(cin, s);. This reads everything until newline, including spaces. For "John Doe", the entire line goes into s. The newline is consumed but not stored.
Syntax differs from cin >>. Pass cin first, string variable second. This function reads from the stream, stopping at line end and removing the newline from the buffer. Use getline for addresses, full names, sentences, or any input with spaces.
It's needed for user-friendly input where people naturally type spaces. Most interactive programs use it.