View Full Version : QBASIC to C++
the_bob
02-13-2006, 03:51 AM
Okay, I've been trying to convert a lot of my QBASIC programs over to C++. It's been going pretty well, but I'm getting stuck. Does C++ have a function similar to QBASIC's 'locate'?
In QB, you can type:
locate 2,2
print "X"
...and your output will be...
(#'s stand for blank spaces)
###
#X#
###
How can I do this in C++?
Ender
02-14-2006, 08:05 PM
So you want a function that prints out a specified number of blank spaces? It seems like such a trivial thing that it wouldn't be in any standard library files. Just write a function like this:
void blankSpaces(int num)
{
for (int i = 0; i < num; i++)
cout << " ";
}
the_bob
02-16-2006, 04:22 AM
No, actually I want a function that prints at a specific point. I have stuff previously written on the screen, and I want to go back up and change part of it.
Let's say my output is this
blahblah
blahblah
blahblah
I want to get this
blahblah
blaXXlah
blahblah
Is it possible to go back up and just add the X's where I want them?
Ender
02-18-2006, 02:50 AM
The only way I know to make a grid on a console in C++ is to to utilize blank spaces and CRLFs (or whatever the newline mapping is on your OS). A GUI gives you more flexibility. I'm no expert at QBASIC, but perhaps this is what it does with "locate x, y?"
void locate(String s, int x, int y)
{
for (int i = 0; i < y; i++)
cout << endl;
for (int j = 0; j < x; j++)
cout << " ";
cout << s << endl;
}
the_bob
02-18-2006, 03:20 AM
Okay, with that I can see how you would go down and right, but, unless I'm reading it wrong, you can't go back up the screen and edit old text, and that's what I need to accomplish.
Ender
02-18-2006, 04:02 AM
It would be easier if you did file I/O. Then you could go "up" and edit old text.
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.