C++ pause lib

Newbie Spellweaver
Joined
May 10, 2009
Messages
12
Reaction score
5
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!!!
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! :thumbup:

Name this pause.h and dont forget to include it in your preprocessor ****.
 
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!!!
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! :thumbup:

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

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).
 
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?
 
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.
 
Back