clear screen?

This is a discussion on clear screen? within the C++ Programming forums, part of the General Programming Boards category; this is the program i am using to mess around and learn C++ on. someone sent me a howto for ...

  1. #1
    Unregistered
    Guest

    clear screen?

    this is the program i am using to mess around and learn C++ on. someone sent me a howto for clearscreen but i cant seem to get it to work.
    --------------------------------------
    #include <iostream>
    #include <string>
    using namespace std;
    #include <conio.h>


    int main()

    {
    char name[100];
    cout<<"Greetings...........";
    cout<<" ";
    cout<<"I am Llethtac, your animated guide through this program.";
    cout<<" ";
    cout<<"I will be your personal VT, or Vitual Tourguide.";
    cout<<" ";
    cout<<"Now that you know who I am, why dont you introduce yourself.";
    cout<<" ";
    cout<<"What would your name be?";
    cin>>name;
    cout<<"Ah, and a fine name you have " <<name;
    cout<<"Now something I find fascinating about your kind is the concept of age, how old are you exactly?";

    clrscr();

    cout<<"Alright, now we can really get started.....";
    return 0;
    }
    ------------------------

    any ideas? i get one error.
    thanks for any help
    bax

  2. #2
    Registered User xlnk's Avatar
    Join Date
    Mar 2002
    Posts
    186
    what compiler are you using, some compilers recognize clrscr() some dont. use this instead, it should work:

    Code:
    system("cls");
    you might want to add one at the beginning of your program to.
    the best things in life are simple.

  3. #3
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    Posts
    279
    also without the system comands...


    [CODE]

    #include <conio.h>

    clrscr();

    [\CODE]

    that should do it

    Regards,
    mathe917

  4. #4
    Unregistered
    Guest
    im usin the mico$oft vc++ compiler
    and thanks for the help
    bax

  5. #5
    Used Registerer jdinger's Avatar
    Join Date
    Feb 2002
    Posts
    1,065
    The conio.h file in the MSVC++ includes doesn't have clrscr();

    Go with what xlnk said:

    system("CLS");

    Also check out:

    http://www.cprogramming.com/boardfaq.html#clear

  6. #6
    Registered User
    Join Date
    Jan 2002
    Posts
    63
    make sure you #include <stdlib.h>

    and use system("clear");
    SS3X

  7. #7
    Hamster without a wheel iain's Avatar
    Join Date
    Aug 2001
    Posts
    1,385
    system("clear") is for the unix environment
    system("cls") is for win/dos environment

    avoid system calls if you can
    for reasons read the faq
    Monday - what a way to spend a seventh of your life

  8. #8
    Registered User
    Join Date
    Mar 2002
    Posts
    203
    By Stoned_Coder from http://www.cprogramming.com/cboard/s...=&threadid=808
    here is the clear screen routine for msvc. written by sunlight that you would have found if you had looked in the faq.

    Code:
    void clrscr() 
    { 
    COORD coordScreen = { 0, 0 }; 
    DWORD cCharsWritten; 
    CONSOLE_SCREEN_BUFFER_INFO csbi; 
    DWORD dwConSize; 
    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); 
    
    GetConsoleScreenBufferInfo(hConsole, &csbi); 
    dwConSize = csbi.dwSize.X * csbi.dwSize.Y; 
    FillConsoleOutputCharacter(hConsole, TEXT(' '), dwConSize, coordScreen, &cCharsWritten); 
    GetConsoleScreenBufferInfo(hConsole, &csbi); 
    FillConsoleOutputAttribute(hConsole, csbi.wAttributes, dwConSize, coordScreen, &cCharsWritten); 
    SetConsoleCursorPosition(hConsole, coordScreen); 
    }
    http://www.cprogramming.com/boardfaq.html#clear
    Last edited by Syneris; 04-05-2002 at 08:15 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CLear Screen Routine
    By AQWst in forum C++ Programming
    Replies: 4
    Last Post: 12-13-2004, 07:24 PM
  2. i am not able to figure ot the starting point of this
    By youngashish in forum C++ Programming
    Replies: 7
    Last Post: 10-07-2004, 02:41 AM
  3. Getting a clear screen...
    By Finchie_88 in forum C++ Programming
    Replies: 13
    Last Post: 09-03-2004, 05:38 PM
  4. Clear Screen Again!!!
    By trang in forum C Programming
    Replies: 3
    Last Post: 12-13-2003, 07:36 AM
  5. Yet another clear screen thread :D
    By kermit in forum Linux Programming
    Replies: 2
    Last Post: 11-20-2003, 04:14 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21