Clear Screen in C using Dev C++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • REDBAIT
    New Member
    • Jan 2007
    • 1

    Clear Screen in C using Dev C++

    Hi Guys,
    Am using Windows 2000 and Dev C++ to create C programs. I'm trying to use clear screen and other graphic functions such as positioning output on screen. Have seen some documents that suggest i use curses.h or system("clear") for clear screen, for example but all this has failed.
  • 123Coder
    New Member
    • Jan 2007
    • 1

    #2
    Originally posted by REDBAIT
    Hi Guys,
    Am using Windows 2000 and Dev C++ to create C programs. I'm trying to use clear screen and other graphic functions such as positioning output on screen. Have seen some documents that suggest i use curses.h or system("clear") for clear screen, for example but all this has failed.
    You must use CONIO2.H header file to use clrscr(); You can get this from devpak.org in the text console category. Get the CONIO library. This will add the Borland Clrscr(); function as well as Dev Cpp's standard Conio.h header file.
    Goodluck! =)

    Comment

    • rdallas
      New Member
      • Sep 2007
      • 2

      #3
      You can use the following C statement to clear your screen:

      Code:
      system("sh -c clear");
      You are executing the sh shell program (usually /bin/sh) and having it execute the built-in "clear" command. You need to use the "-c" option to tell sh that the next option is a built-in command, not a file to be executed. See the man page on sh for more info.

      Comment

      • rdallas
        New Member
        • Sep 2007
        • 2

        #4
        The previous post assumes you are using Unix. On Windows, you can clear the screen by using the "cls" command; there is no "clear" command on Windows. I was able to use the following code to clear the screen (command window) using Borland C++ 5.5.1 for Win32 on Windows XP:

        Code:
        #include <iostream>
        
        int main( int argc, char *argv[] )
        {
            system("cls");
        }

        Comment

        • vinay khurana
          New Member
          • Feb 2012
          • 1

          #5
          A lot of try to clear the sacreen in a program of c using dev c++ on OS 7,but never works

          Comment

          • JazibBahir
            New Member
            • Feb 2012
            • 2

            #6
            Now use this

            clrscr();

            Comment

            • sanjoy adhikary
              New Member
              • Apr 2014
              • 1

              #7
              i want a code using programm

              Comment

              • Deepak5218
                New Member
                • Mar 2015
                • 1

                #8
                Use system("cls") including the stdlib.h in the begining of the programm...

                See the example......


                #include<stdio. h>
                #include<conio. h>
                #include<string .h>
                #include<stdlib .h>
                main()
                {
                char name[10]="Deepak";
                char pass[20]="Sharma";
                char uname[10],upass[20];
                printf("======= =============== =LOGIN PANEL========== =============== ==\n");
                printf("Usernam e : ");
                scanf("%s",unam e);
                printf("Passwor d : ");
                scanf("%s",upas s);
                system("cls");
                if(strcmp(name, uname)||strcmp( pass,upass))
                {
                printf("\tACCES S DENIED\n\n");
                printf("Enter a valid username and password...");
                }
                else
                {

                printf("\tACCES S GRANTED\n\n");
                printf("Welcome %s, Happy to see you again :)",name);
                }
                getch();
                }

                Comment

                • riteshsuprchamp
                  New Member
                  • Sep 2015
                  • 1

                  #9
                  please include stdlib.h file and then call system("cls") and enjoy.
                  #include<stdlib .h>

                  system("cls");

                  Comment

                  Working...