Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 system("pause") help
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Scooter341




PostPosted: Thu Apr 28, 2005 1:01 pm   Post subject: system("pause") help

I'm using DevCpp and I am hoping to find out whether there is a way I can control what is diplayed when I use

code:

system ("pause");


I was hoping to change it from "Press Any Key To Continue..."
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Thu Apr 28, 2005 1:09 pm   Post subject: (No subject)

When you use this, you're simply calling a external program. "pause" is a program on Windows which simply displays the "Press any key to continue..." message, then terminates.

You can (and should, if you wish to move beyond Windows) simply write your own equivalent by printing a string to standard output and getting some input.
Martin




PostPosted: Thu Apr 28, 2005 1:24 pm   Post subject: (No subject)

Yes. System calls are an easy way to write bad code. Use getch ()
wtd




PostPosted: Thu Apr 28, 2005 1:27 pm   Post subject: (No subject)

I believe he's using C++, so using a C function would be inappropriate where C++ can easily fill the role.

code:
char answer;
std::cin >> answer;
jamonathin




PostPosted: Thu Apr 28, 2005 1:28 pm   Post subject: (No subject)

Is that the same concept as this?
c++:

int wait;
std::cin >> wait;


edit: bah neva mind Razz
md




PostPosted: Thu Apr 28, 2005 2:15 pm   Post subject: (No subject)

If your sticking to windows you can always use the windows system call Sleep(), it takes the number of milliseconds to sleep for; although then you'll only be delaying for a set amount of time
Cinjection




PostPosted: Fri Jun 10, 2005 2:28 pm   Post subject: (No subject)

DO NOT USE system("PAUSE"); !
It will hinder the portability of your program. Use 'cin.get()' to pause a program. If you use system("PAUSE"),that program will only work on a windows machine. With cin.get(); you increase its portability.
MysticVegeta




PostPosted: Sat Jun 11, 2005 8:37 am   Post subject: (No subject)

oh lol i do it the cheap way ->
code:
int foo;
cin >> foo;
return 0;
Sponsor
Sponsor
Sponsor
sponsor
Cinjection




PostPosted: Sat Jun 11, 2005 8:47 am   Post subject: (No subject)

MysticVegeta wrote:
oh lol i do it the cheap way ->
code:
int foo;
cin >> foo;
return 0;


ummm, why? Just go:

code:

cout<<"Hey Man, i'll pause now"<<endl;
cin.get();
return 0;


I don't see why you'd do that. That just makes you declare a var that makes your program 32 bytes bigger.
md




PostPosted: Sat Jun 11, 2005 9:49 am   Post subject: (No subject)

Cinjection wrote:
MysticVegeta wrote:
oh lol i do it the cheap way ->
code:
int foo;
cin >> foo;
return 0;


ummm, why? Just go:

code:

cout<<"Hey Man, i'll pause now"<<endl;
cin.get();
return 0;


I don't see why you'd do that. That just makes you declare a var that makes your program 32 bytes bigger.


I think that's 32 bits only 4 bytes Wink But realy declaring an int like that is nothing; it's actually created on the stack so there is no size overhead; and only minimal performance overhead (basically only the time it takes to increment the stack pointer). Either way works; but the second is much cleaner.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 10 Posts ]
Jump to:   


Style:  
Search: