airdevil,
[tab]
Is there a command that flushes the output buffer? Is so What is it? the
flush command flushes the output buffer if you not want a line feed,
endl flushes the buffer with a line feed. You are probably correct about the
clrscr which was what I thought but I wasn't too sure.
[tab]There is a stream output class that does have the functionality of conio.h, it is
constream and is called from the header
constrea.h. The list below shows some of the manipulators.
Manipulator[tab]Action
clreol[tab]Clears to end of line in text window.
delline[tab]Deletes line in the text window.
highvideo[tab]Selects high-intensity characters.
insline[tab]Inserts a blank line in the text window.
lowvideo[tab]Selects low-intensity characters.
normvideo[tab]Selects normal-intensity characters.
setattr(int)[tab]Sets screen attributes.
setbk(int)[tab]Sets new character color.
setclr(int)[tab]Sets the color.
setcrsrtype(int)[tab]Selects cursor appearance.
setxy(int, int)[tab]Positions the cursor at the specified position.
[tab]Here's an example
Code:
#include <constrea.h>
int main(void) {
constream win1;
win1.window(1, 1, 40, 20); // Initialize the desired space.
win1.clrscr(); // Clear this rectangle.
// Use the parameterized manipulator to set screen attributes.
win1 << setattr((BLUE<<4) | WHITE)
<< "This text is white on blue.";
// Use this parameterized manipulator to specify output area.
win1 << setxy(10, 10)
<< "This text is in the middle of the window.";
return(0);
}
You can create multiple constreams, each writing to its own portion of the screen. Then, you can output to any of them without having to reset the window each time.
#include <constrea.h>
int main(void) {
constream demo1, demo2;
demo1.window( 1, 2, 40, 10 );
demo2.window( 1, 12, 40, 20 );
demo1.clrscr();
demo2.clrscr();
demo1 << "Text in first window" << endl;
demo2 << "Text in second window" << endl;
demo1 << "Back to the first window" << endl;
demo2 << "And back to the second window" << endl;
return(0);
}
[tab]The table and examples came from Borland's help file. I know this works under C++ 5.2 and earlier. I have not tried it with version 5.5.
James P. Cottingham
All opinions are mine alone and do not necessarily reflect those of my employer.