how to clear screen in c - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

how to clear screen in c

mikecoonmikecoon Posts: 61Member
I want to be able to clear the screen after each input. how do i do this?
how do i implement the dos command 'cls' in my c program.
yes, i am a newbie.

Comments

  • stoberstober Posts: 9,765Member ✭✭✭
    : I want to be able to clear the screen after each input. how do i do this?
    : how do i implement the dos command 'cls' in my c program.
    : yes, i am a newbie.
    :

    system("cls");

  • luckyklluckykl Posts: 28Member
    : : I want to be able to clear the screen after each input. how do i do this?
    : : how do i implement the dos command 'cls' in my c program.
    : : yes, i am a newbie.
    : :
    :
    : system("cls");
    :
    :

    [code]
    #include

    system("cls");
    [/code]

    :-)

    or with scrclr(); in conio.h

  • stoberstober Posts: 9,765Member ✭✭✭
    :
    : or with scrclr(); in conio.h
    :
    :

    that is non-anscii c so not all compilers will have that function.
  • luckyklluckykl Posts: 28Member
    [b][red]This message was edited by luckykl at 2003-9-13 5:47:14[/red][/b][hr]
    Correct :-)
  • eet349eet349 Posts: 1Member
    i think you mean non-[u]ANSI[/u] C
  • khaledelkhateebkhaledelkhateeb egyptPosts: 1Member

    What is the difference between get char( );
    get che ( );
    get ch( ) ;
    and get s();

  • DavidTheGreatDavidTheGreat IndiaPosts: 3Member

    @khaledelkhateeb said:
    What is the difference between get char( );
    get che ( );
    get ch( ) ;
    and get s();

    getchar() takes one character
    getche() would also take one character but would not display it on the screen
    getch() is similar to getchar except that it is in conio.h
    gets() would take a whole string and store it in a character array

  • Malcolm_McLeanMalcolm_McLean Posts: 254Member ✭✭

    It's a simple question, but there's no easy answer.

    The core C language doesn't have a concept of screens. It has standard input ans standard output, which these days are almost always connected to DOS boxes or Unix terminals, but historically were often teletypes. So it sees output as a series of characters.
    But the computer sees the DOS or Unix terminal as a program in its own right, and can treat it as an N x M raster of characters. conio.h or curses.h (for DOS or Unix) contain functions that do that.
    Another answer, which has already been given, is to issue the system cls comand.

    Another answer is that Ascii 0x0B, or form feed, will often be honoured, and move the terminal to a fresh screen.
    You can also print lots of newlines

Sign In or Register to comment.