I want to clear a portion of screen - How??

Discussion in 'C Programming' started by Rajendran, Sep 2, 2006.

  1. Rajendran

    Rajendran Guest

    I just want to clear the above three lines from the current position,
    so that I can start printing my results from that point. In short I
    want to clear a portion of my screen.

    Note: I work in the UNIX environment using gcc compiler. And I'm not a
    super user.

    I want a "simple solution".

    I tried the combination of "\r\b" escape sequences. But \b is not
    taking me back to the above line?
    I urgently need the key for this.
    Please help me achieving this.

    I daily visit my topic to see whether I got the answer or not!
    Thank you.
    Rajendran, Sep 2, 2006
    1. Advertisements

  2. Rajendran said:
    Standard C has no solution to your problem. (Standard C does not offer
    full-screen addressing.)

    I suggest you ask your question in comp.unix.programmer where (I trust) the
    experts there will be able to offer you a platform-specific solution.
    Richard Heathfield, Sep 2, 2006
    1. Advertisements

  3. Rajendran

    Skarmander Guest

    See question 19.4 in the FAQ: http://www.c-faq.com
    comp.unix.programmer is your friend.
    The (n)curses library is pretty simple. There's probably not much to gain
    from even simpler solutions, since they won't transfer to other platforms,
    and learning them is a waste of time.
    \b is backspace, which "moves the active position to the previous position
    on the current line. If the active position is at the initial position of a
    line, the behavior of the display device is unspecified." In other words,
    you can't use backspace that way and expect it to work.

    Skarmander, Sep 2, 2006
  4. Rajendran

    Rich Gibbs Guest

    Rajendran said the following, on 09/02/06 03:00:
    The C language has no standard facilities dealing with the "screen", and
    not all implementations have anything that could be so described.
    A better place to post this question would be comp.unix.programmer.

    In a Unix/Linux environment, your best bet is probably to use
    screen-handling tools contained in the 'ncurses(3)' package. They are
    pretty simple to use, and will allow your program to work with a wide
    range of display devices.
    Rich Gibbs, Sep 2, 2006
  5. Rajendran

    Peyman Guest

    I'm not quite sure about this, but google for an implementation of
    "conio.h" header file, and find the implementation for function
    clearScreen() or something like that, it should look something like:
    printf("03[4[/j/r"); // roughly to give an idea about how strange it
    you might do the thing by a bit of hacking into this code.
    but still, comp.unix.programmer is your friend!
    Peyman, Sep 3, 2006
  6. Peyman said:
    That advice is not going to do him any good. The probability of there being
    a <conio.h> header on his Unix system is vanishingly small, and the
    probability that it is useful to him is even smaller.

    That advice, however, works fine.
    Richard Heathfield, Sep 3, 2006
  7. Rajendran

    Rajen Guest

    Thanks to all of you!
    I already posted this question as you said - on unix.progammer

    Finally I started learning ncurses but the example programmes are
    giving strange results on my screen. Anyhow ncurses is interesting.

    Anyway I "still welcome" your solutions
    Rajen, Sep 3, 2006
  8. Rajendran

    Rajen Guest

    Hello Peyman,
    could you please give me any websites relating to this.
    what does /j do? I started searching the net. Reply me.
    Thank you.
    Rajen, Sep 3, 2006
  9. Rajendran

    W H G Guest

    The answer to clearing the screen is to use whatever function
    your compiler vendor supplied. If the compiler was meant for
    regular computer use it probably has a function - but it is off topic
    for this group. RTFM

    Ignoring that advice, make sure you have and ANSI screen driver
    installed, and look up the codes for it. I went back to MSDOS 4
    document. The driver is ANSI.SYS. All the codes start with
    an escape character, aka, octal 033, decimal 27 or hex 1B.
    Clear the screen is escape [2J so printing that should clear the screen.
    I suspect the previous poster worked from memory ( "something like").

    ------------- W H G
    W H G, Sep 3, 2006
  10. Rajendran

    Rajen Guest

    Thanks WHG,
    What does RTFM Mean? I came to know the esacpe sequences and I'm
    comfortable with them.
    esc[4A - Takes the cursor four lines up from current postion
    esc[#B - " # lines down "
    esc[#C - # columns forward
    esc[#D #columns backward
    Rajen, Sep 4, 2006
  11. Rajendran

    Coos Haak Guest

    Op 4 Sep 2006 05:07:10 -0700 schreef Rajen:
    Coos Haak, Sep 4, 2006
  12. Rajendran

    Peyman Guest

    Yes, exactly, thank you for correcting me, what I meant was:
    or as you said, it can be:
    Peyman, Sep 4, 2006
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.