|
 |
|
Dev Articles Community Forums
> Programming
> C/C++ Help
|
How to pause in C
Discuss How to pause in C in the C/C++ Help forum on Dev Articles. How to pause in C C/C++ Help forum discussing building and maintaining applications in C/C++. Find out why these languages are the foundation on which other languages are built.
|
|
 |
|
|
|
|

Dev Articles Community Forums Sponsor:
|
|
|

July 14th, 2005, 10:16 AM
|
|
Registered User
|
|
Join Date: Jul 2005
Posts: 24
Time spent in forums: 6 h 3 m 19 sec
Reputation Power: 0
|
|
How to pause in C
Hi everyone,
I am a beginner of C, and C++. Now, I have a question, when I write C++, I will write a cin.get () ; to pause the window.
But, what should I write in C to have the same function??
Because I run the C programme, the window close too fast before I can see anything.
Thank you very much for your help.
Regards,
Sun.
|

July 14th, 2005, 10:40 AM
|
|
Registered User
|
|
Join Date: Jul 2005
Posts: 2
Time spent in forums: 28 m 49 sec
Reputation Power: 0
|
|
|
I always just add a separate variable, and for a cin at the end of the program. I think I only run into the window-dropping problem with VS 6.0, seems to hang on the screen untill closed with .net. I'm sure there's a pause function of some sort out there, but I've always felt it was easier to do it this way:
int main()
{
Int m;
--All of your code here--
cin >> m;
}
Kind of sloppy, but it works.
|

July 14th, 2005, 11:13 AM
|
|
Registered User
|
|
Join Date: Jul 2005
Posts: 24
Time spent in forums: 6 h 3 m 19 sec
Reputation Power: 0
|
|
Thanks a lot!!!
I learn something from you. 
|

July 14th, 2005, 11:13 AM
|
 |
Registered Loser
|
|
Join Date: Jul 2005
Location: Retardation Nation...
Posts: 347

Time spent in forums: 4 Days 3 h 13 m 45 sec
Reputation Power: 8
|
|
I agree, There probably is a better way of doing it, but I do the same thing. If you are writing a program were you want your user to see the final result of there last question or something it always helps to have the last operation, the user inputting some type of integer. and just to add to your code Diocletian, you could also do something like this!!
Code:
int main()
{
Int m;
--All of your code here--
cout>>" Enter 1 To exit \n";
cin >> m;
}
Just to make it a little more formal to the user 
|

July 14th, 2005, 02:04 PM
|
 |
:bcon: moderator
|
|
Join Date: Apr 2005
Location: int main()
Posts: 351

Time spent in forums: 2 Days 23 h 24 m 9 sec
Reputation Power: 9
|
|
|
The C equivilent of "cin.get()" is "getchar()", it does the exact same thing.
__________________
Officially a member of the Itsacon fan club. Beer blasts are every friday at Viper_SB's house. I bring the chips.

|

February 25th, 2010, 08:47 AM
|
|
Registered User
|
|
Join Date: Feb 2010
Posts: 1
Time spent in forums: 3 m 58 sec
Reputation Power: 0
|
|
|
pause in c
just type the following code after writing the c program ie at the end before closing the main function
system("PAUSE");
return 0;
that's it will work i guess
|

February 25th, 2010, 10:54 PM
|
|
Registered User
|
|
Join Date: Feb 2010
Posts: 2
Time spent in forums: 2 h 24 m 31 sec
Reputation Power: 0
|
|
|
Pause a C program
You could use
sleep(n);
where n is the number of seconds you want to pause for.
|

May 20th, 2011, 12:45 PM
|
|
Registered User
|
|
Join Date: May 2011
Posts: 1
Time spent in forums: 7 m 54 sec
Reputation Power: 0
|
|
Quote: | Originally Posted by Sun Hi everyone,
I am a beginner of C, and C++. Now, I have a question, when I write C++, I will write a cin.get () ; to pause the window.
But, what should I write in C to have the same function??
Because I run the C programme, the window close too fast before I can see anything.
Thank you very much for your help.
Regards,
Sun. |
another simple method is to use:
while(!getch());
you will be paused until any key is hit,
delay(xxx); will pause for xxx ticks too.
|

June 7th, 2011, 10:26 PM
|
|
Contributing User
|
|
Join Date: Jan 2011
Posts: 37
Time spent in forums: 7 h 23 m 53 sec
Reputation Power: 3
|
|
|
system("pause");
return 0;
Seems the most convenient method. And it doesn't require use of a variable.
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|