Text location

Discussion in 'C Programming' started by Mike, Apr 7, 2004.

  1. Mike

    Mike Guest

    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?
    Mike, Apr 7, 2004
    #1
    1. Advertising

  2. Mike <> 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 () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "How come even in my fantasies everyone is a jerk?"
    - Daria Morgendorfer
    Joona I Palaste, Apr 7, 2004
    #2
    1. Advertising

  3. Mike

    Ben Pfaff Guest

    (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[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.\
    \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\
    );}return 0;}
    Ben Pfaff, Apr 7, 2004
    #3
  4. Mike

    Dan Pop Guest

    In <> (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:
    Dan Pop, Apr 7, 2004
    #4
  5. Dan Pop <> scribbled the following:
    > In <> (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 () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "Ice cream sales somehow cause drownings: both happen in summer."
    - Antti Voipio & Arto Wikla
    Joona I Palaste, Apr 7, 2004
    #5
  6. Mike

    Mike Guest

    (Dan Pop) wrote in message news:<c51ec4$e3f$>...
    > In <> (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
    Mike, Apr 8, 2004
    #6
  7. Mike

    Dan Pop Guest

    In <c51f45$neg$> Joona I Palaste <> writes:

    >Dan Pop <> scribbled the following:
    >> In <> (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:
    Dan Pop, Apr 8, 2004
    #7
  8. Dan Pop <> scribbled the following:
    > In <c51f45$neg$> Joona I Palaste <> writes:
    >>Dan Pop <> scribbled the following:
    >>> In <> (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 () ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "Insanity is to be shared."
    - Tailgunner
    Joona I Palaste, Apr 8, 2004
    #8
  9. 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.
    Thomas Stegen, Apr 8, 2004
    #9
  10. Mike

    Vic Dura Guest

    On 8 Apr 2004 14:22:18 GMT, RE: Re: Text location Joona I Palaste
    <> 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.
    Vic Dura, Apr 8, 2004
    #10
  11. Mike

    Dan Pop Guest

    In <c53n6q$33e$> Joona I Palaste <> writes:

    >Dan Pop <> scribbled the following:
    >> In <c51f45$neg$> Joona I Palaste <> writes:
    >>>Dan Pop <> scribbled the following:
    >>>> In <> (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:
    Dan Pop, Apr 8, 2004
    #11
  12. On Thu, 8 Apr 2004, Dan Pop wrote:
    >
    > Joona I Palaste <> writes:
    > >Dan Pop <> scribbled the following:
    > >> Joona I Palaste <> writes:
    > >>>Dan Pop <> scribbled the following:
    > >>>> (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
    Arthur J. O'Dwyer, Apr 8, 2004
    #12
  13. Mike

    Dan Pop Guest

    In <> Vic Dura <> writes:

    >On 8 Apr 2004 14:22:18 GMT, RE: Re: Text location Joona I Palaste
    ><> 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:
    Dan Pop, Apr 8, 2004
    #13
  14. Mike

    Dan Pop Guest

    In <> "Arthur J. O'Dwyer" <> writes:


    >On Thu, 8 Apr 2004, Dan Pop wrote:
    >>
    >> Joona I Palaste <> writes:
    >> >Dan Pop <> scribbled the following:
    >> >> Joona I Palaste <> writes:
    >> >>>Dan Pop <> scribbled the following:
    >> >>>> (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:
    Dan Pop, Apr 8, 2004
    #14
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Luke Dalessandro
    Replies:
    0
    Views:
    601
    Luke Dalessandro
    Jan 15, 2006
  2. zxo102
    Replies:
    0
    Views:
    403
    zxo102
    Aug 1, 2006
  3. saiho.yuen
    Replies:
    3
    Views:
    411
    kaeli
    Sep 14, 2004
  4. Replies:
    2
    Views:
    135
  5. Alex Bird
    Replies:
    3
    Views:
    170
    Thomas 'PointedEars' Lahn
    May 9, 2008
Loading...

Share This Page