Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you display characters or strings starting in a set position?

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
0
Third try posting this topic. Posted the other two in the wrong forum. Think I got it right this time.

Okay, in TI-BASIC, if you want to start the text going on the 3rd line, fourth space in, you write the command line...

:Output(3,4,"YADAYADAYADA")

This allows you to do animation, because it doesn't erase what was there previously.

So how do you do that in C++?

Btw, I'm using Visual C++ 6.0

Thanks for your time.
 
Oh! ::slaps head::

I'm using just simple Console Applications. That's all they teach you how to use in High School Programming.
frown.gif
 
Use the api SetConsoleScreenPosition.

Here is an example

void main()
{
COORD c = {3,10};
HANDLE hScreenBuffer = GetStdHandle(STD_OUTPUT_HANDLE);

SetConsoleCursorPosition(hScreenBuffer,c);
SetConsoleTextAttribute(hScreenBuffer,FOREGROUND_RED | BACKGROUND_RED | FOREGROUND_INTENSITY);

printf("Hello World");
}
 
if you are using windows95 or windows98 and if you have the
ansi.sys file in your "autoexec.bat".
You might symply do it like this:

#include<stdio.h>
#define POS(x,y) printf(&quot;\033[%d;%dH&quot;,x,y);
void main()
{
POS(3,4);
printf(&quot;YADAYADAYADA&quot;);
}
 
Didn't work. It displayed <-[3;4HYADAYADAYADA.
(Note, <- was one character, I just don't know how to type it)

#define POS(x,y) printf(&quot;\033[%d;%dH&quot;,x,y);
Was that statement right?
 
And, wundram, I what library is SetConsolePosition in?

Again, I am only using a simple Win32 Console application.
 
#define POS(x,y) printf(&quot;\033[%d;%dH&quot;, x, y)
Yes these statement is perfectly right,i have found it in a programming book.And i have use it a couple time with visual c++.

But to be able to use it,you need to follow these two conditions.

1- First you need to have win95 or win98 as your current operating system.

2- Second ,you might need to modify the &quot;config.sys&quot; not the &quot;autoexec.bat&quot; file by including the following line in it:
device = c:\windows\command\ansi.sys
(notice:if you dont add this line,it will never work)
(you will find the &quot;config.sys&quot; in your c:\ root)
then you will need to restart your computer in order for the changes to take place.






 
Well, THERE'S the problem. I would be using a school computer. I seriously doubt I would be authorized to add that. But I can always ask. What does it do, anyway?
 
And I tried Wundram's thing, including the neccesary libraries. It does the exact same thing as Leibnitz'.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top