Output Stream Functions for Windows BGI


Syntax

#include "graphics.h"

extern ostringstream bgiout;

void outstream(ostringstream& out=bgiout);

void outstreamsy(int x, int y, ostringstream& out=bgiout);

Description
The winbgim package supports a globally defined output stream called bgiout. This output stream can be written to just like cout or any other output stream. However, the information written to bgiout does not appear in the graphics window until the program calls outstream or outstreamxy.

The outstream and outstreamxy functions work like outtext and outtextxy functions except that they print from an ostringstream rather than from an ordinary string. The outstream function prints its information in the active graphics window at the current pointer. The outstreamxy function prints its information in the active graphics window at coordinates (x,y).

Both functions clear the ostreamstream after printing its information.

Both functions use the global bgiout as the default value for the ostringstream.

bgiout Examples:

    #include "graphics.h"

    

    initwindow(400, 400);

    bgiout << "Hello, World!" << endl;

    bgiout << 42 << endl;

    outstreamxy(100, 100);

    getch( );

    closegraph( );