The WinBuf Class

The WinBuf class is designed to provide a Windows-based interface for cout and cin, thereby easing the task of porting non-Windows code. Using the code with the Microsoft Foundation Classes, you can redefine cout, cin, and cerr to interact with a window instead of a console-based interface. It can be used with a few lines at the beginning and end of your code, and a few more files.

This implementation supports buffering of input and output. Right now the input and output are split into two fields, and maybe I'll fix this later. If you can suggest any changes or improvements, email me at For background, please see Google's archive regarding my initial post to news and the responses I got. There is a tutorial with step-by-step instructions on how to use the class. You are free to peruse the files:

I could not get the assignment of cout restored to its original value. Microsoft's implementation of rdbuf() does not allow assignment. Instead they have ostream_withassign, which doesn't allow me to restore the old value of cout. I have a copy of a news post that describes the problem more. If anyone can help we with this, it would be extremely appreciated.

Example screenshots are below. The unix-style console is on the left, and the Windows dialog box is on the left.

Unix I/O Windows I/O

Copyright 1997 David Coppit. Permission to use and modify this code for research purposes is granted to provided that this copyright statement retained in all derivative software.