| View previous topic :: View next topic |
| Author |
Message |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Mon Aug 11, 2008 2:13 pm Post subject: |
|
|
| slovach wrote: | | kitterz wrote: | | dEEznutz wrote: |
double edit: Hmm, I think it's working now because when I clicked start debugging it opened up a CMD and I got no errors. However, the cmd closed to fast for me to see anything. Is this what supposed to happen? |
Or you can just use
Sleep (); |
Er no, don't do this. It's just going to sit there, stalled and unresponsive until it's time is up. |
not really...he is doing nothing else after the Sleep(), if he puts it there, so it should make no difference.
|
|
| Back to top |
|
 |
TraxMate Master Cheater
Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Mon Aug 11, 2008 2:19 pm Post subject: |
|
|
| lurc wrote: | They just stop the command line and wait for user-input.
sync - Synchronize input buffer with source of characters
ignore - Extract and discard characters
(Taken from cplusplus) |
Or he can use getchar; it does the same.
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Mon Aug 11, 2008 3:27 pm Post subject: |
|
|
| TraxMate wrote: | | lurc wrote: | They just stop the command line and wait for user-input.
sync - Synchronize input buffer with source of characters
ignore - Extract and discard characters
(Taken from cplusplus) |
Or he can use getchar; it does the same. |
Why? He's using C++.
|
|
| Back to top |
|
 |
TraxMate Master Cheater
Reputation: 0
Joined: 01 Mar 2008 Posts: 363
|
Posted: Mon Aug 11, 2008 3:39 pm Post subject: |
|
|
| noz3001 wrote: | | TraxMate wrote: | | lurc wrote: | They just stop the command line and wait for user-input.
sync - Synchronize input buffer with source of characters
ignore - Extract and discard characters
(Taken from cplusplus) |
Or he can use getchar; it does the same. |
Why? He's using C++. |
me to it works in c++ to.
|
|
| Back to top |
|
 |
dEEznutz Grandmaster Cheater
Reputation: 0
Joined: 29 Nov 2007 Posts: 514
|
Posted: Mon Aug 11, 2008 8:09 pm Post subject: |
|
|
| Zand wrote: | Yes.
Put
| Code: |
std::cin.sync();
std::cin.ignore();
|
before return 0; |
Uh, is there a different way for the CMD to not close by itself instead of using this?
_________________
Learning C++ |
|
| Back to top |
|
 |
hcavolsdsadgadsg I'm a spammer
Reputation: 26
Joined: 11 Jun 2007 Posts: 5801
|
Posted: Mon Aug 11, 2008 8:10 pm Post subject: |
|
|
| dEEznutz wrote: | | Zand wrote: | Yes.
Put
| Code: |
std::cin.sync();
std::cin.ignore();
|
before return 0; |
Uh, is there a different way for the CMD to not close by itself instead of using this? |
Run the program from the command prompt
|
|
| Back to top |
|
 |
dEEznutz Grandmaster Cheater
Reputation: 0
Joined: 29 Nov 2007 Posts: 514
|
Posted: Mon Aug 11, 2008 8:14 pm Post subject: |
|
|
Yeah, how do I do that..?
_________________
Learning C++ |
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Mon Aug 11, 2008 8:51 pm Post subject: |
|
|
Go to run -> cmd.
| Code: |
cd C:\dir\dir
hello
|
cd to where you have that program, then type "hello" assuming your program name is hello.exe.
|
|
| Back to top |
|
 |
FullyAwesome I post too much
Reputation: 0
Joined: 05 Apr 2007 Posts: 4438 Location: Land Down Under
|
Posted: Tue Aug 12, 2008 1:39 am Post subject: |
|
|
sorry for my post, i didn't mean to teach people bad things. that's why i said that it's just my opinion and it helped me out, but that might be because i didn't just learn vb.net. anyway sorry and don't listen to me in the future.
_________________
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Tue Aug 12, 2008 2:29 am Post subject: |
|
|
| TraxMate wrote: | | noz3001 wrote: | | TraxMate wrote: | | lurc wrote: | They just stop the command line and wait for user-input.
sync - Synchronize input buffer with source of characters
ignore - Extract and discard characters
(Taken from cplusplus) |
Or he can use getchar; it does the same. |
Why? He's using C++. |
me to it works in c++ to. |
It's unnecessary shit.
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Tue Aug 12, 2008 4:02 am Post subject: |
|
|
| dEEznutz wrote: | | Uh, is there a different way for the CMD to not close by itself instead of using this? | It's a feature of Windows XP/Vista's cmd prompt. You could try finding an alternative (tweaked?) cmd prompt or switch to Win9x or something :P Also, there's a param called /K, which leaves the window open, in cmd. If you're using a shortcut to launch your program, you might want to add that one.
Btw.. Here's a great tool: http://www.microsoft.com/windowsxp/Downloads/powertoys/Xppowertoys.mspx -> "Open Command Window Here". Just right click on folder, click the Open CMD here and tada, there's a prompt for you in the right folder :)
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8588 Location: 127.0.0.1
|
Posted: Tue Aug 12, 2008 5:19 am Post subject: |
|
|
| kitterz wrote: | | dEEznutz wrote: |
double edit: Hmm, I think it's working now because when I clicked start debugging it opened up a CMD and I got no errors. However, the cmd closed to fast for me to see anything. Is this what supposed to happen? |
Or you can just use
Sleep (); |
To pause a console, sleep would probably be the last thing someone should use. (Unless the programmer is specifically creating a timed pause before automatically closing.) Using sleep, as slovach stated, is a timed pause, this isn't an indefinate thing and using some huge number or something to force it paused is not good practice.
Theres no reason to not use the iostream example already given. And if it is a must, you can include conio.h and use _getch(); to yield a pause effect. But I recommend sticking with sync/ignore.
_________________
- Retired. |
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Tue Aug 12, 2008 11:51 am Post subject: |
|
|
| Wiccaan wrote: | | But I recommend sticking with sync/ignore. | I second that, but there's one thing above every other: don't pause the execution at all. Recently I came across with a lil' tool, the only negative thing in the tool was that it did wait for input at the end of program. God thank the source was available :)
|
|
| Back to top |
|
 |
Jaak Expert Cheater
Reputation: 0
Joined: 02 Jul 2008 Posts: 176
|
Posted: Wed Aug 13, 2008 6:22 am Post subject: |
|
|
| rapion124 wrote: | | Why does everyone use std::*? Why don't they just use printf()? |
Better yet, why don't people do using namespace std; ? You see this big ass peace of code with std: : everywhere and it looks sloppy =O.
|
|
| Back to top |
|
 |
Zand Master Cheater
Reputation: 0
Joined: 21 Jul 2006 Posts: 424
|
Posted: Wed Aug 13, 2008 8:26 am Post subject: |
|
|
| Because the std namespace is huge.
|
|
| Back to top |
|
 |
|