Text location

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mike

    #1

    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?
  • Joona I Palaste

    #2
    Re: Text location

    Mike <Whats_up_505@h otmail.com> scribbled the following:[color=blue]
    > I am just begninning C and I was wondering this:[/color]
    [color=blue]
    > Just like in QBASIC yuo can use the LOCATE y, x function. Is there a
    > way to do this in C?[/color]

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

    --
    /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
    \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
    "How come even in my fantasies everyone is a jerk?"
    - Daria Morgendorfer

    Comment

    • Ben Pfaff

      #3
      Re: Text location

      Whats_up_505@ho tmail.com (Mike) writes:
      [color=blue]
      > 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?[/color]

      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[]="ABCDEFGHIJKLM NOPQRSTUVWXYZab cdefghijklmnopq rstuvwxyz.\
      \n",*q="kl BIcNBFr.NKEzjwC IxNJC";int i=sizeof p/2;char *strchr();int putchar(\
      );while(*q){i+= strchr(p,*q++)-p;if(i>=(int)si zeof p)i-=sizeof p-1;putchar(p[i]\
      );}return 0;}

      Comment

      • Dan Pop

        #4
        Re: Text location

        In <8556585d.04040 70850.77142bcc@ posting.google. com> Whats_up_505@ho tmail.com (Mike) writes:
        [color=blue]
        >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?[/color]

        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@ifh.de

        Comment

        • Joona I Palaste

          #5
          Re: Text location

          Dan Pop <Dan.Pop@cern.c h> scribbled the following:[color=blue]
          > In <8556585d.04040 70850.77142bcc@ posting.google. com> Whats_up_505@ho tmail.com (Mike) writes:[color=green]
          >>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?[/color][/color]
          [color=blue]
          > 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.[/color]

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

          --
          /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
          \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
          "Ice cream sales somehow cause drownings: both happen in summer."
          - Antti Voipio & Arto Wikla

          Comment

          • Mike

            #6
            Re: Text location

            Dan.Pop@cern.ch (Dan Pop) wrote in message news:<c51ec4$e3 f$2@sunnews.cer n.ch>...[color=blue]
            > In <8556585d.04040 70850.77142bcc@ posting.google. com> Whats_up_505@ho tmail.com (Mike) writes:[/color]
            [color=blue]
            > 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.
            >[/color]
            Example

            LOCATE2, 5
            PRINT "Hello World!"


            OBTW thanks guys for the stuff! :D

            Comment

            • Dan Pop

              #7
              Re: Text location

              In <c51f45$neg$2@o ravannahka.hels inki.fi> Joona I Palaste <palaste@cc.hel sinki.fi> writes:
              [color=blue]
              >Dan Pop <Dan.Pop@cern.c h> scribbled the following:[color=green]
              >> In <8556585d.04040 70850.77142bcc@ posting.google. com> Whats_up_505@ho tmail.com (Mike) writes:[color=darkred]
              >>>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?[/color][/color]
              >[color=green]
              >> 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.[/color]
              >
              >No. It moves the console cursor to row #y, column #x.[/color]

              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@ifh.de

              Comment

              • Joona I Palaste

                #8
                Re: Text location

                Dan Pop <Dan.Pop@cern.c h> scribbled the following:[color=blue]
                > In <c51f45$neg$2@o ravannahka.hels inki.fi> Joona I Palaste <palaste@cc.hel sinki.fi> writes:[color=green]
                >>Dan Pop <Dan.Pop@cern.c h> scribbled the following:[color=darkred]
                >>> In <8556585d.04040 70850.77142bcc@ posting.google. com> Whats_up_505@ho tmail.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?[/color]
                >>[color=darkred]
                >>> 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.[/color]
                >>
                >>No. It moves the console cursor to row #y, column #x.[/color][/color]
                [color=blue]
                > I actually knew that, but I wanted to point out the ambiguity of the
                > question, *especially* considering the subject line.[/color]

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

                --
                /-- Joona Palaste (palaste@cc.hel sinki.fi) ------------- Finland --------\
                \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
                "Insanity is to be shared."
                - Tailgunner

                Comment

                • Thomas Stegen

                  #9
                  Re: Text location

                  Joona I Palaste wrote:
                  [color=blue]
                  >
                  > Well you sure were subtle about it. You had me fooled into thinking you
                  > didn't know it.
                  >[/color]

                  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.

                  Comment

                  • Vic Dura

                    #10
                    Re: Text location

                    On 8 Apr 2004 14:22:18 GMT, RE: Re: Text location Joona I Palaste
                    <palaste@cc.hel sinki.fi> wrote:
                    [color=blue][color=green][color=darkred]
                    >>>> 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.[/color][/color]
                    >[color=green]
                    >> I actually knew that, but I wanted to point out the ambiguity of the
                    >> question, *especially* considering the subject line.[/color]
                    >
                    >Well you sure were subtle about it. You had me fooled into thinking you
                    >didn't know it.[/color]

                    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.

                    Comment

                    • Dan Pop

                      #11
                      Re: Text location

                      In <c53n6q$33e$1@o ravannahka.hels inki.fi> Joona I Palaste <palaste@cc.hel sinki.fi> writes:
                      [color=blue]
                      >Dan Pop <Dan.Pop@cern.c h> scribbled the following:[color=green]
                      >> In <c51f45$neg$2@o ravannahka.hels inki.fi> Joona I Palaste <palaste@cc.hel sinki.fi> writes:[color=darkred]
                      >>>Dan Pop <Dan.Pop@cern.c h> scribbled the following:
                      >>>> In <8556585d.04040 70850.77142bcc@ posting.google. com> Whats_up_505@ho tmail.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.[/color][/color]
                      >[color=green]
                      >> I actually knew that, but I wanted to point out the ambiguity of the
                      >> question, *especially* considering the subject line.[/color]
                      >
                      >Well you sure were subtle about it. You had me fooled into thinking you
                      >didn't know it.[/color]

                      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@ifh.de

                      Comment

                      • Arthur J. O'Dwyer

                        #12
                        Re: Text location


                        On Thu, 8 Apr 2004, Dan Pop wrote:[color=blue]
                        >
                        > Joona I Palaste <palaste@cc.hel sinki.fi> writes:[color=green]
                        > >Dan Pop <Dan.Pop@cern.c h> scribbled the following:[color=darkred]
                        > >> Joona I Palaste <palaste@cc.hel sinki.fi> writes:
                        > >>>Dan Pop <Dan.Pop@cern.c h> scribbled the following:
                        > >>>> Whats_up_505@ho tmail.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.[/color]
                        > >[color=darkred]
                        > >> I actually knew that, but I wanted to point out the ambiguity of the
                        > >> question, *especially* considering the subject line.[/color]
                        > >
                        > >Well you sure were subtle about it. You had me fooled into thinking you
                        > >didn't know it.[/color]
                        >
                        > 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! ;-)[/color]

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

                        -Arthur

                        Comment

                        • Dan Pop

                          #13
                          Re: Text location

                          In <gmua70tsc3d7dg gk0bits7cvpmc3m s7vk3@4ax.com> Vic Dura <vpdura@XXXhiwa ay.net> writes:
                          [color=blue]
                          >On 8 Apr 2004 14:22:18 GMT, RE: Re: Text location Joona I Palaste
                          ><palaste@cc.he lsinki.fi> wrote:
                          >[color=green][color=darkred]
                          >>>>> 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.[/color]
                          >>[color=darkred]
                          >>> I actually knew that, but I wanted to point out the ambiguity of the
                          >>> question, *especially* considering the subject line.[/color]
                          >>
                          >>Well you sure were subtle about it. You had me fooled into thinking you
                          >>didn't know it.[/color]
                          >
                          >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.[/color]

                          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@ifh.de

                          Comment

                          • Dan Pop

                            #14
                            Re: Text location

                            In <Pine.LNX.4.5 8-035.04040812533 70.6092@unix41. andrew.cmu.edu> "Arthur J. O'Dwyer" <ajo@nospam.and rew.cmu.edu> writes:

                            [color=blue]
                            >On Thu, 8 Apr 2004, Dan Pop wrote:[color=green]
                            >>
                            >> Joona I Palaste <palaste@cc.hel sinki.fi> writes:[color=darkred]
                            >> >Dan Pop <Dan.Pop@cern.c h> scribbled the following:
                            >> >> Joona I Palaste <palaste@cc.hel sinki.fi> writes:
                            >> >>>Dan Pop <Dan.Pop@cern.c h> scribbled the following:
                            >> >>>> Whats_up_505@ho tmail.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.[/color]
                            >>
                            >> 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! ;-)[/color]
                            >
                            > But if you hadn't yet begun QBASIC, how would you know the syntax
                            >that language uses to refer to string variables?? ;-)[/color]

                            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@ifh.de

                            Comment

                            Working...