Thread: Clear screen function

  1. #1
    Registered User
    Join Date
    Nov 2013
    Posts
    49

    Clear screen function

    HI, I'm looking for a way to clear the screen on the commando prompt.

    I have heard about clrscr(); with #include <conio.h> but i have not been able to make it work.

    Help is much appreciated.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    That depends entirely on your system and is not standard. You'll have to look up how your system clears the screen and do that.

  3. #3
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    First, its command prompt. We are not a war ;p

    You probably wasn't able to make it work, because this is not standard C. Some compilers/systems support and some not. As a result, I suggest you not to use it!! Imagine yourself writing code and then giving it to another guy who wouldn't be able to use it, because you had used not-standard libraries, as conio.h

    I do not know how to clear the screen via code. One can type "clear" in the cmd and clear the screen, but this is when a program is not executing.
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

  4. #4
    Registered User
    Join Date
    Nov 2013
    Posts
    49
    I use windows, i thought about printf a lot of \n in a function
    and just call that when i want the screen cleared which should also translate to different systems I think

  5. #5
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Location
    Nice, France
    Posts
    2,694
    printf() is standard C, yes, but why do you want that bad to clear the screen?
    Code - functions and small libraries I use


    It’s 2014 and I still use printf() for debugging.


    "Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson

  6. #6
    Registered User
    Join Date
    Nov 2013
    Posts
    49
    its neat for the program I'm working on with my group, we dont "need" it but im curious so

  7. #7

  8. #8
    Registered User
    Join Date
    Nov 2013
    Posts
    49
    awesome thanks Matticus

  9. #9
    Registered User
    Join Date
    Nov 2012
    Posts
    1,393
    The FAQ doesn't mention another option: install the ncurses or pdcurses library and use the console functions to clear the screen. It's way better than conio.h.

  10. #10
    Registered User
    Join Date
    Dec 2012
    Posts
    307
    or use win api functions, so you can "goto" an x, and y value, and just print over the text that is there, that way if you want just one line to clear, and leave the rest, you can just clear one line at a time!

    it is what i do, as a screen clear and reprint ( of like a menu) becomes kinda "flashy"

    ( just read faq, and seen Option 6, thats almost what i do!)

    and ncurses, or another library, mantioned as part of option 2!
    Last edited by Crossfire; 11-13-2013 at 03:24 PM.

  11. #11
    11DE784A SirPrattlepod's Avatar
    Join Date
    Aug 2013
    Posts
    485
    HI, I'm looking for a way to clear the screen on the commando prompt.
    First, its command prompt. We are not a war ;p
    I like the term commando prompt and I think I'll name my terminals from now on because I have a yeti suit and also commando costume and face paint that I rarely get to use. With my commando prompt I can dress up every day. The main problem I have is that my helmet is a racing car helmet so I might have to go to the army surplass store and get a proper commando helmet. I can probably use the new helmet in Call of Duty as well so I may as well get it

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screen clear function
    By ynf_dude in forum C++ Programming
    Replies: 10
    Last Post: 08-05-2011, 04:54 PM
  2. clear screen function
    By mrprogrmr in forum C Programming
    Replies: 16
    Last Post: 12-28-2004, 10:49 AM
  3. Clear Screen Function?
    By Punkture in forum C Programming
    Replies: 3
    Last Post: 05-05-2003, 09:25 PM
  4. Clear Screen function..
    By Jez_Master in forum C++ Programming
    Replies: 4
    Last Post: 04-08-2002, 11:23 AM
  5. clear screen function
    By sballew in forum C Programming
    Replies: 4
    Last Post: 10-22-2001, 09:24 PM