Im Frustrated!

This is a discussion on Im Frustrated! within the C++ Programming forums, part of the General Programming Boards category; If we can't even clear the screen without ANSI escape codes and ANSI.SYS how are we supose to make programs?? ...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    44

    Im Frustrated!

    If we can't even clear the screen without ANSI escape codes and ANSI.SYS how are we supose to make programs??
    Is there another way?

  2. #2
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    Code:
    #include <stdlib.h>
    #include <iostream.h>
    
    int main()
    {
    cout<<"I am text"<<endl;
    system("CLS");
    cout<<"My buddy is gone"<<endl;
    cin.get();
    }

  3. #3
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    Add return 0 to the above.
    Truth is a malleable commodity - Dick Cheney

  4. #4
    Registered User foniks munkee's Avatar
    Join Date
    Nov 2001
    Posts
    343
    Eh.. not the best way to do it. The FAQ has all the answers
    "Queen and huntress, chaste and fair,
    Now the sun is laid to sleep,
    Seated in thy silver chair,
    State in wonted manner keep."

  5. #5
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >Add return 0 to the above.
    Not required with C++. If the return statement is omitted from main then the return value will be 0.

    -Prelude
    My best code is written with the delete key.

  6. #6
    Registered User
    Join Date
    Jun 2002
    Posts
    79
    #include<conio.h>
    #include<iostream.h>
    int main()
    {
    cout<<"Press a key to clear the screen...";
    getch();
    clrscr(); //requires conio.h
    return 0
    }

    This function works on Borland C++ compilers. Try it on yours, it just might work. An alternative is to use system("CLS").
    Last edited by sundeeptuteja; 06-26-2002 at 01:53 PM.

  7. #7
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    Well, Prelude, I'll defer to you every time, but if that's so, why have you made such a big deal about it in previous posts? Just asking...
    Truth is a malleable commodity - Dick Cheney

  8. #8
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    Yea, I forgot to put it in, and I think you are supposed to have a return statement unless you use void main(), which you shouldn't

  9. #9
    Registered User
    Join Date
    Jun 2002
    Posts
    44

    Im Frustrated!

    Thank you but theres still a problem:
    consider this snippet:
    cout << "Hi!\n";
    getchar();
    system("CLS");
    cout << "Hi again!\n";
    You would think it say 'Hi!',then wait for a carriage return/line-feed,then clear screen,and say 'Hi again!',but it doesn't.It waits for a carriage return/line-feed,then clears screen and prints
    Hi!
    Hi again!
    And please tell me c++ has a way to clear the screen on its own!

  10. #10
    Registered User
    Join Date
    Jan 2002
    Posts
    559

    Re: Im Frustrated!

    Originally posted by Powerfull Army
    And please tell me c++ has a way to clear the screen on its own!:
    It sure does. Try this:
    PHP Code:
    for (int i 025i++)
    {
       for (
    int j 080j++)
          
    cout << "  ";

    That should do it.
    Truth is a malleable commodity - Dick Cheney

  11. #11
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    Code:
    #include <windows.h>
    #include <conio.h>
    #include <iostream>
    using namespace std;
    
    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);
    }
    
    int main(int argc, char *argv[])
    {
       cout << "Hello";
       getch();
       clrscr();
       cout << "Hello Again!";
    
       return 0;
    }
    READ THE FAQ
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  12. #12
    Registered User
    Join Date
    Jun 2002
    Posts
    44

    Unhappy

    thanks okie smokie and salvenis but:
    salvenis,that isn't realy clearing the screen,its scrolling the screen,that'd be good for a replacement but i think c++ outa have a good,simple,complete,and authentic way to do such a simple task such as clearing the screen.
    And okiesmokie thanks for the function but it still clears the screen before couting.

  13. #13
    . Driveway's Avatar
    Join Date
    May 2002
    Posts
    469
    Do you mean it does this?

    Output:
    Hi!
    (clear screen)
    Hi Again!

    because if it does that's what it's supposed to do.

  14. #14
    Registered User
    Join Date
    Jun 2002
    Posts
    44
    No,it does this
    (wait for enter press)
    (clears screen)
    Hi!
    Hi again!
    Its frustrating isn't it?

  15. #15
    Registered User
    Join Date
    Jun 2002
    Posts
    44

    Exclamation

    If anyone has an answer to this disgusting riddle please don't hide it
    I know people make full-blown applications with c++ all the time so theres got to be a simple way to clear the screen

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. frustrated bout char array
    By royuco77 in forum C++ Programming
    Replies: 2
    Last Post: 07-11-2005, 09:10 AM
  2. Getting frustrated
    By kippwinger in forum C++ Programming
    Replies: 17
    Last Post: 07-02-2003, 03:55 PM
  3. A Bit Frustrated....
    By DirX in forum C++ Programming
    Replies: 3
    Last Post: 04-14-2003, 10:29 PM
  4. so confused and frustrated
    By ct26torr in forum C Programming
    Replies: 2
    Last Post: 02-13-2003, 09:40 PM
  5. so frustrated!!!!
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 11-28-2001, 05:44 PM

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