I'm creating a program that connects to an IP address on a specific port, then uses the recv() function to return the data from the address. I don't know how to go about creating the buffer the data will save to. At first I was just going to create a char array for it to save to, but then I would run the risk for buffer overflow. Next, I considered having the user input the number of bytes to receive. This would work, but would be impractical when dealing with a large amount of data or when retrieving an unknown amount of data. Would there be a way to set an array up at a certain size, then as soon as it is full, print it to stdout, then clear it out and start writing from the beginning? I am worried that while the array is being printed and cleared, more data would be received and lost. Any suggestions?