Text location

M

Mike

I am just begninning C and I was wondering this:

Just like in QBASIC yuo can use the LOCATE y, x function. Is there a
way to do this in C?
 
J

Joona I Palaste

Mike said:
I am just begninning C and I was wondering this:
Just like in QBASIC yuo can use the LOCATE y, x function. Is there a
way to do this in C?

Not portably. Some platforms provide non-standard extensions, for
example "conio" for Microsoft systems.
 
B

Ben Pfaff

I am just begninning C and I was wondering this:

Just like in QBASIC yuo can use the LOCATE y, x function. Is there a
way to do this in C?

This is in the FAQ.

19.4: How can I clear the screen?
How can I print text in color?
How can I move the cursor to a specific x, y position?

A: Such things depend on the terminal type (or display) you're
using. You will have to use a library such as termcap,
terminfo, or curses, or some system-specific routines, to
perform these operations. On MS-DOS systems, two functions
to look for are clrscr() and gotoxy().

For clearing the screen, a halfway portable solution is to print
a form-feed character ('\f'), which will cause some displays to
clear. Even more portable (albeit even more gunky) might be to
print enough newlines to scroll everything away. As a last
resort, you could use system() (see question 19.27) to invoke
an operating system clear-screen command.

References: PCS Sec. 5.1.4 pp. 54-60, Sec. 5.1.5 pp. 60-62.
 
D

Dan Pop

In said:
I am just begninning C and I was wondering this:

Just like in QBASIC yuo can use the LOCATE y, x function. Is there a
way to do this in C?

Since some of us haven't yet begun QBASIC, you may want to explain what
the LOCATE y, x QBASIC function is supposed to do. If it's about locating
a substring inside a string, strstr() does the job.

Dan
 
J

Joona I Palaste

Since some of us haven't yet begun QBASIC, you may want to explain what
the LOCATE y, x QBASIC function is supposed to do. If it's about locating
a substring inside a string, strstr() does the job.

No. It moves the console cursor to row #y, column #x.
 
M

Mike

In <[email protected]> (e-mail address removed) (Mike) writes:
Since some of us haven't yet begun QBASIC, you may want to explain what
the LOCATE y, x QBASIC function is supposed to do. If it's about locating
a substring inside a string, strstr() does the job.
Example

LOCATE2, 5
PRINT "Hello World!"


OBTW thanks guys for the stuff! :D
 
D

Dan Pop

In said:
No. It moves the console cursor to row #y, column #x.

I actually knew that, but I wanted to point out the ambiguity of the
question, *especially* considering the subject line.

Dan
 
J

Joona I Palaste

I actually knew that, but I wanted to point out the ambiguity of the
question, *especially* considering the subject line.

Well you sure were subtle about it. You had me fooled into thinking you
didn't know it.
 
T

Thomas Stegen

Joona said:
Well you sure were subtle about it. You had me fooled into thinking you
didn't know it.

To me his point was clear as crystal. His BASIC skills were clearly
impossible to deduce from what he said, but clearly not the point.
 
V

Vic Dura

Well you sure were subtle about it. You had me fooled into thinking you
didn't know it.

Yes, he had me fooled too.

Now he has me fooled into thinking that he can't admit he was wrong;
possibly because that would be an egregious (but common) character
trait in someone who delights in correcting others.
 
D

Dan Pop

In said:
Well you sure were subtle about it. You had me fooled into thinking you
didn't know it.

There was a flaw in my original post, that was a good give away: my
advice made sense only for the LOCATE y$, x$ syntax! ;-)

Dan
 
A

Arthur J. O'Dwyer

There was a flaw in my original post, that was a good give away: my
advice made sense only for the LOCATE y$, x$ syntax! ;-)

But if you hadn't yet begun QBASIC, how would you know the syntax
that language uses to refer to string variables?? ;-)

-Arthur
 
D

Dan Pop

In said:
Yes, he had me fooled too.

Now he has me fooled into thinking that he can't admit he was wrong;
possibly because that would be an egregious (but common) character
trait in someone who delights in correcting others.

I have no problems admitting my ignorance on most BASIC dialects, QBASIC
included. However, that ignorance is not complete...

Dan
 
D

Dan Pop

But if you hadn't yet begun QBASIC, how would you know the syntax
that language uses to refer to string variables?? ;-)

It seems to be one of the very few features common to all BASIC dialects
and I have already demonstrated certain familiarity with some of them,
in past discussions with Joona ;-)

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top