phycowelder...if you are on Windoze...I created a function cout(x,y) that behaves like, in QB, locate(x,y): print.
It's easy to use. The solution uses namespaces, so the function as written here is my::cout()
my_cout.h
Code:
#include <iostream>
#include <iosfwd>
#ifndef MY_COUT
#define MY_COUT
namespace my {
void locate(int x, int y );
std::ostream& cout( int x = -1, int y = -1 );// {
void cls();
void wait();
}
#endif //MY_COUT
my_cout.cpp
Code:
#include "my_cout.h"
#include <windows.h>
void my::locate(int x, int y )
{
COORD cur = { x, y };
SetConsoleCursorPosition( GetStdHandle( STD_OUTPUT_HANDLE ), cur );
}
#include <string>
void my::cls(){
static const std::string b(2000, ' ');
my::cout(0,0) << b;
my::locate(0,0);
}
std::ostream& my::cout( int x/* = -1*/, int y/* = -1*/ ) {
if(~x || ~y){
my::locate(x,y);
}
return std::cout;
}
void my::wait(){
std::cin.get();
}
testdriver.cpp
Code:
#include "my_cout.h"
using namespace my;
int main(){
cout() << "my::cout() behaves just like std::cout\n";
cout() << "with letters following the cursor";
wait();
cout(20,12) << "but you can use the function with arguments";
cout(20,13) << "to print to arbitrary coordinates";
wait();
cls();
cout(0,0) << "All";
wait();
cout(76, 0) << "you";
wait();
cout(75, 23) << "need";
wait();
cout(0,23) << "is";
wait();
cout(38, 12) << "love";
wait();
cls();
cout(25, 12) << "goodbye cruel world";
cout(0,24) << "Press Enter to continue";
std::cin.get();
int t=clock();
for(int z=0; z<100; z++){
cout(z%80, z%25) << z;
cls();
}
t=clock()-t;
cls();
int t2=clock();
for(int z=0; z<100; z++){
cout(z%80, z%25) << z;
system("cls");
}
t2 = clock() - t2;
cls();
cout()<< "my::cout is " << t2/t << " times as fast as std::system(\"cls\")" << std::endl;
wait();
return 0;
}
Hope this is useful to someone...