Thread: cls in C

  1. #1
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259

    cls in C

    um how do I do a csls in C I might have asked this be4 but in that case I cant remember the answer and I cant find the topic anyway....
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  2. #2
    Unleashed
    Join Date
    Sep 2001
    Posts
    1,765
    system("cls");
    Read the FAQ.

    Clearing the screen
    The world is waiting. I must leave you now.

  3. #3
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    cls only works in DOS-WIN, in unix is clear. maybe try something like this

    Code:
    #ifdef UNIX
      #define CLS "clear"
    #else
      #define CLS "cls"
    #endif
    Then you just call, system(CLS);

  4. #4
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    I`m using a unix so I should use clear then?
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

  5. #5
    Registered User Vber's Avatar
    Join Date
    Nov 2002
    Posts
    807
    if you're using linux, you can use system("clear"); or use curses to make the job, example:
    Code:
    #include <curses.h> 
    
    void clrscr(void)
    {
        static int init;
    
        if (init == 0)
        {
            initscr();
            init = 1;
        }
    
        clear();
        refresh();
    }

  6. #6
    Registered User Frobozz's Avatar
    Join Date
    Dec 2002
    Posts
    546
    Or just convert this function from Pascal to C:

    Code:
    procedure Cls(Color : byte); assembler;
    asm
     mov    AX, $A000    { move the video segment into AX cause }
     mov    ES, AX       { you can't load a segment reg directly }
     mov    AL, [Color]  
     mov    AH, AL       { REG / REG is faster than MEM /REG }
     mov    CX, 32000    { 64k / 2 since we're using word values }
     xor    DI, DI       { fast way of saying DI = 0 }
     rep    STOSW        { mov ES:[DI], AL; dec CX, jcxz done }
    end;
    It'll clear the screen filling it with a color.

  7. #7
    Wannabe Coding God
    Join Date
    Mar 2003
    Posts
    259
    you guys cant make up for minds eh?
    They say that if you play a Windows Install CD backwords, you hear satanic messages. That's nothing; play it forward and it installs Windows.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 03-05-2009, 10:25 AM
  2. cls() vs system("cls")
    By swgh in forum C++ Programming
    Replies: 6
    Last Post: 10-26-2006, 03:13 PM
  3. Replies: 15
    Last Post: 05-13-2006, 09:28 PM
  4. BASIC's CLS equivalent in C#
    By sean in forum C# Programming
    Replies: 4
    Last Post: 07-24-2004, 09:44 PM
  5. cls
    By fkheng in forum C Programming
    Replies: 4
    Last Post: 06-10-2003, 06:45 AM