Re: clrscr Compiler Independent functions

Discussion in 'C++' started by Jonathan Mcdougall, Nov 23, 2004.

  1. > I have been programming in C++ with borland compiler for a while now.
    > But when I try to compile the same programs with other complilers like
    > mingw, digital mars etc. there are problems with functions like
    > getch() and clrscr().


    That's what happens when you use non-standard functions.

    > I have used these functions in many of my programs. Is there another
    > funciton
    > similer to these which are supported by other compilers?


    For clrscr(), no. For getch(), you could use std::cin by specifying to
    the user you want the enter key, though other characters will be echoed
    to the screen.

    In that kind of situation, it would have been better to encapsulate
    these non standard calls to a single place, for example

    void wait_for_key()
    {
    }

    That way, when you change the compiler, you only have to change that
    function.

    > I don't want
    > to use
    > system("pause") because I want the getch() function to return the key
    > that was pressed. I use that in many of my programs.


    Too bad.


    Jonathan
     
    Jonathan Mcdougall, Nov 23, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. AHR

    Problem with clrscr()

    AHR, Jan 26, 2004, in forum: C++
    Replies:
    3
    Views:
    8,586
    ensvhiiotus_17
    Aug 7, 2008
  2. Dfschweiss
    Replies:
    1
    Views:
    416
    Michiel Salters
    Dec 1, 2004
  3. Michele 'xjp'

    POSIX and getch(), clrscr()

    Michele 'xjp', Jul 20, 2007, in forum: C++
    Replies:
    8
    Views:
    1,404
    Thomas Dickey
    Jul 27, 2007
  4. Replies:
    1
    Views:
    769
  5. vikaskumar sharma

    How to clear screen (as clrscr in c) in java?

    vikaskumar sharma, Oct 6, 2012, in forum: Java
    Replies:
    9
    Views:
    1,724
    Knute Johnson
    Oct 7, 2012
Loading...

Share This Page