473,513 Members | 2,881 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Text location

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?
Nov 14 '05 #1
17 1830
Mike <Wh**********@hotmail.com> scribbled the following:
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.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"How come even in my fantasies everyone is a jerk?"
- Daria Morgendorfer
Nov 14 '05 #2
Mike <Wh**********@hotmail.com> scribbled the following:
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.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"How come even in my fantasies everyone is a jerk?"
- Daria Morgendorfer
Nov 14 '05 #3
Wh**********@hotmail.com (Mike) writes:
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.

--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Nov 14 '05 #4
Wh**********@hotmail.com (Mike) writes:
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.

--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Nov 14 '05 #5
In <85**************************@posting.google.com > Wh**********@hotmail.com (Mike) writes:
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
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #6
In <85**************************@posting.google.com > Wh**********@hotmail.com (Mike) writes:
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
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #7
Dan Pop <Da*****@cern.ch> scribbled the following:
In <85**************************@posting.google.com > Wh**********@hotmail.com (Mike) writes:
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.


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

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Ice cream sales somehow cause drownings: both happen in summer."
- Antti Voipio & Arto Wikla
Nov 14 '05 #8
Dan Pop <Da*****@cern.ch> scribbled the following:
In <85**************************@posting.google.com > Wh**********@hotmail.com (Mike) writes:
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.


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

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Ice cream sales somehow cause drownings: both happen in summer."
- Antti Voipio & Arto Wikla
Nov 14 '05 #9
Da*****@cern.ch (Dan Pop) wrote in message news:<c5**********@sunnews.cern.ch>...
In <85**************************@posting.google.com > Wh**********@hotmail.com (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
Nov 14 '05 #10
In <c5**********@oravannahka.helsinki.fi> Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Dan Pop <Da*****@cern.ch> scribbled the following:
In <85**************************@posting.google.com > Wh**********@hotmail.com (Mike) writes:
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.


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
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #11
Dan Pop <Da*****@cern.ch> scribbled the following:
In <c5**********@oravannahka.helsinki.fi> Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Dan Pop <Da*****@cern.ch> scribbled the following:
In <85**************************@posting.google.com > Wh**********@hotmail.com (Mike) writes:
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.


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.


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

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Insanity is to be shared."
- Tailgunner
Nov 14 '05 #12
Joona I Palaste wrote:

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.

--
Thomas.

Nov 14 '05 #13
On 8 Apr 2004 14:22:18 GMT, RE: Re: Text location Joona I Palaste
<pa*****@cc.helsinki.fi> wrote:
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.

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.


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.

--
To reply to me directly, remove the XXX characters from my email address.
Nov 14 '05 #14
In <c5**********@oravannahka.helsinki.fi> Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Dan Pop <Da*****@cern.ch> scribbled the following:
In <c5**********@oravannahka.helsinki.fi> Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Dan Pop <Da*****@cern.ch> scribbled the following:
In <85**************************@posting.google.com > Wh**********@hotmail.com (Mike) writes:
>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.

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.


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
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #15

On Thu, 8 Apr 2004, Dan Pop wrote:

Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Dan Pop <Da*****@cern.ch> scribbled the following:
Joona I Palaste <pa*****@cc.helsinki.fi> writes:
Dan Pop <Da*****@cern.ch> scribbled the following:
> Wh**********@hotmail.com (Mike) writes:
>>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.

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.


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! ;-)


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

-Arthur

Nov 14 '05 #16
In <gm********************************@4ax.com> Vic Dura <vp****@XXXhiwaay.net> writes:
On 8 Apr 2004 14:22:18 GMT, RE: Re: Text location Joona I Palaste
<pa*****@cc.helsinki.fi> wrote:
> 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.

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.


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
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #17
In <Pi**********************************@unix41.andre w.cmu.edu> "Arthur J. O'Dwyer" <aj*@nospam.andrew.cmu.edu> writes:

On Thu, 8 Apr 2004, Dan Pop wrote:

Joona I Palaste <pa*****@cc.helsinki.fi> writes:
>Dan Pop <Da*****@cern.ch> scribbled the following:
>> Joona I Palaste <pa*****@cc.helsinki.fi> writes:
>>>Dan Pop <Da*****@cern.ch> scribbled the following:
>>>> Wh**********@hotmail.com (Mike) writes:
>>>>>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.
>>>
>>>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.
>
>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! ;-)


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
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #18

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1537
by: nephish | last post by:
Hey there, i have a text file with a bunch of values scattered throughout it. i am needing to pull out a value that is in parenthesis right after a certain word, like the first time the word 'foo' is found, retrieve the values in the next set of parenthesis (bar) and it would return 'bar' i think i can use re to do this, but is there some...
9
4741
by: Pam Ammond | last post by:
I need the code to update the database when Save is clicked and a text field has changed. This should be very easy since I used Microsoft's wizards for the OleDBAdapter and OleDBConnection, and DataSet; and all I'm doing is showing one record in text fields, allowing the user to modify the text fields, and then updating the database again...
4
2588
by: Arif Çimen | last post by:
Hi to everybody, I have chnged a button text in design mode. But After compiling and executing the program the text of the button do not change to new value. Any Ideas? Thaks for helps.
6
4182
by: Lance Geeck | last post by:
I have a simple form where I am using a dataset called Client. On the data entry screen, there are name, address, city state and zip. I have the fields bound to the dataset field. (Properties screen: Data bindings then Text ) When I run the program and make a change to an existing record in the City text box, the Dataset value for this...
11
2093
by: F. Michael Miller | last post by:
I'd like to copy the listing of a directory (& sub directories) to a text file in vb.net. I'm looking for teh equivilant of the DOS command dir /s > TargetFile.txt. Thanks!
7
4196
by: Andrew McKendrick | last post by:
Hi, I've noticed a bug in VB.NET (latest .NET Framework)... - I have a TabControl on a form with several tabs. - Each tab contains text boxes that are bound to fields in a data source (DataBindings). - When I display a record and then try to access the .Text property of one of the text boxes on any tab except the current tab, the result...
9
4666
by: sicvic | last post by:
I was wondering if theres a way where python can read through the lines of a text file searching for a key phrase then writing that line and all lines following it up to a certain point, such as until it sees a string of "---------------------" Right now I can only have python write just the line the key phrase is found in. Thanks,...
13
1916
by: Marc | last post by:
The first part of the below writes the name and location of all buttons on a from to a text file. The second part reads that information back in and recreates the buttons. My problem is reading the location value back in where I marked ?????????????????????. As it wont accept a string value? Private Sub Save_Click(ByVal sender As...
2
1519
by: JonWB | last post by:
Hi, I am very new to .Net and have recently taken over someone else’s project. I am developing an asp webpage using C#. I have an asp:table that is populated using data from a database. However, there is also a column that contains checkboxes and a column that contains text boxes like so: Location | Stock | Issue (checkbox column) | ...
0
2709
by: JamesOo | last post by:
I have the code below, but I need to make it searchable in query table, below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only, cannot serch by combine 3 table) Example I have the query table below, how do I make the code to seach based on the query from this: SELECT...
0
7269
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7394
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7559
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7123
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.