One thing I've done is use std::replace() to replace spaces with pipes "|" prior to sending the string via a winsock connection and the inverse on the client side with recv() and replace() in a while loop to parse the pipes in the buffer before outputting to std::cout to turn the pipes back into spaces. If you're using fstream for file i/o as Vince1027 mentioned getline() is great.