Hi Guys

Quick question.

What do you think the best way is to break up pipped data coming into a C++ programming from command line into x number of bytes (eg. 5 bytes at a time) for manipulation?

I have the following at the moment, but not sure if this is correct and how to handle the tail of the message where i may have less than 5 bytes / characters in the data block.

Code:
        while (!cin.eof())
        {
            int size = 5;
            
            char *buffer = new char[1];
            buffer[0] = '\0';
            cout << buffer << "\n";
            cin.read(buffer, size);
eg. 1234567

Would show me
12345
67
45

The 45 should not be there!

Thanks