C++ pause lib

Results 1 to 4 of 4
  1. #1
    Proficient Member LatinKid is offline
    MemberRank
    May 2009 Join Date
    New MexicoLocation
    173Posts

    C++ pause lib

    Do you use dev C++ and are always tired of having to put system("pause"); every single time you want to pause? No need to fret anymore! With my tiny library (i guess you can call it that) you will be pausing in no time!!!
    Spoiler:

    Code:
    #ifndef PAUSE_H
    #define PAUSE_H
    #include <iostream>
    using namespace std;
    
    //void sP();
    //void ssP();
    
    void sP(){
        system("pause");
    }
    
    void ssP(){
        system("pause>nul");
    }
    
    void csP(string phrase){
        cout<<endl<<phrase<<endl;
        system("pause>nul");
    }
    
    #endif
    sP= regular system pause
    ssP= silent system pause
    csP= coder input system pause


    The way you use csP is instead of the same old boring "Press any key to continue", you can make it say "BAI!!!" or whatever. Just declare&init a string and pass it when you call csP(). And no need to endl before calling csP()!

    Im a beginner and i JUST learned how to make headers so give me a break!

    Name this pause.h and dont forget to include it in your preprocessor shit.


  2. #2
    Not working on UnitedFlyf Mootie is offline
    MemberRank
    Apr 2009 Join Date
    1,589Posts

    Re: C++ pause lib

    Quote Originally Posted by LatinKid View Post
    Do you use dev C++ and are always tired of having to put system("pause"); every single time you want to pause? No need to fret anymore! With my tiny library (i guess you can call it that) you will be pausing in no time!!!
    Spoiler:

    Code:
    #ifndef PAUSE_H
    #define PAUSE_H
    #include <iostream>
    using namespace std;
    
    //void sP();
    //void ssP();
    
    void sP(){
        system("pause");
    }
    
    void ssP(){
        system("pause>nul");
    }
    
    void csP(string phrase){
        cout<<endl<<phrase<<endl;
        system("pause>nul");
    }
    
    #endif
    sP= regular system pause
    ssP= silent system pause
    csP= coder input system pause


    The way you use csP is instead of the same old boring "Press any key to continue", you can make it say "BAI!!!" or whatever. Just declare&init a string and pass it when you call csP(). And no need to endl before calling csP()!

    Im a beginner and i JUST learned how to make headers so give me a break!

    Name this pause.h and dont forget to include it in your preprocessor shit.
    First, a library(lib) is not a couple of functions. In general, a "lib" refers to a .lib file(a collection of re-usable code).

    Second, system("pause") is a highly expensive operation(resource wise). I advise you not to use this, and especially not to advise others to use this.

    Here's a small article that briefly explains some alternatives to system("pause"):
    Things to Avoid in C/C++ system("pause")

    In my opinion, you shouldn't be releasing anything related to C++ without at least a year's experience. Your time is better spent learning than making a feeble attempt at helping others(especially when you may be wrong in the first place).

  3. #3
    Proficient Member LatinKid is offline
    MemberRank
    May 2009 Join Date
    New MexicoLocation
    173Posts

    Re: C++ pause lib

    Quote Originally Posted by xLethal View Post
    First, a library(lib) is not a couple of functions. In general, a "lib" refers to a .lib file(a collection of re-usable code).

    Second, system("pause") is a highly expensive operation(resource wise). I advise you not to use this, and especially not to advise others to use this.

    Here's a small article that briefly explains some alternatives to system("pause"):
    Things to Avoid in C/C++ system("pause")

    In my opinion, you shouldn't be releasing anything related to C++ without at least a year's experience. Your time is better spent learning than making a feeble attempt at helping others(especially when you may be wrong in the first place).
    Thanks for the constructive criticism i guess?

    So what does cin.get() do besides pause? Is that its only function?

  4. #4
    Not working on UnitedFlyf Mootie is offline
    MemberRank
    Apr 2009 Join Date
    1,589Posts

    Re: C++ pause lib

    Quote Originally Posted by LatinKid View Post
    Thanks for the constructive criticism i guess?

    So what does cin.get() do besides pause? Is that its only function?
    It basically does what system("pause"); does, but more efficiently. Using the system() function should generally be avoided. It doesn't matter so much for something like this, but if your app calls a function 10 times in one second you'll notice a difference in system() vs a standard C++ function.



Advertisement