| View previous topic :: View next topic |
| Author |
Message |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Sun Sep 28, 2008 10:47 am Post subject: |
|
|
Too many characters to be written, use:
@Fredd: .sync discards all the characters in the input buffer, so there won't be any newlines. Then .ignore works kinda the same as you'd be reading from the keyboard with .get or something, but instead of storing the read stuff, it just ignores them.
|
|
| Back to top |
|
 |
deleted19776 I post too much
Reputation: 11
Joined: 29 Apr 2007 Posts: 3838
|
Posted: Sun Sep 28, 2008 11:07 am Post subject: |
|
|
Dude.., why are you talking about loop statements here?
@GMZorita:
I heard that System("PAUSE"); is not a good idea for some reason...
|
|
| Back to top |
|
 |
manc Grandmaster Cheater
Reputation: 1
Joined: 16 Jun 2006 Posts: 551
|
Posted: Sun Sep 28, 2008 11:09 am Post subject: |
|
|
| waxxup wrote: |
@GMZorita:
I heard that System("PAUSE"); is not a good idea for some reason... |
It will get the job done, no doubt, just not as efficiently. Also, it will leave "Press any key to continue...." on your screen which is annoying.
_________________
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Sun Sep 28, 2008 11:21 am Post subject: |
|
|
| waxxup wrote: | Dude.., why are you talking about loop statements here?
@GMZorita:
I heard that System("PAUSE"); is not a good idea for some reason... |
Because if you shove a loop at the end it will never close. I was joking about the goto thing though. Just don't use system.
|
|
| Back to top |
|
 |
DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Sun Sep 28, 2008 12:18 pm Post subject: |
|
|
FUCK!, do this:
for(;;)Sleep(10); //2 semicolon(girls) 1 line(cup)
|
|
| Back to top |
|
 |
deleted19776 I post too much
Reputation: 11
Joined: 29 Apr 2007 Posts: 3838
|
Posted: Sun Sep 28, 2008 2:24 pm Post subject: |
|
|
| Also, how come SYSTEM is not a valid identifier because it gives me compiling errors when i tried it. Should i put another #include on there? If yes, then tell me what it is, I did put #include <iostream> and #include <string>.
|
|
| Back to top |
|
 |
scuba111223 Master Cheater
Reputation: 0
Joined: 10 Sep 2008 Posts: 275
|
Posted: Sun Sep 28, 2008 2:53 pm Post subject: |
|
|
| add #include <stdlib.h> and try making SYSTEM all lowercase, that might do the trick.
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Sun Sep 28, 2008 3:41 pm Post subject: |
|
|
| Rot1 wrote: | FUCK!, do this:
for(;;)Sleep(10); //2 semicolon(girls) 1 line(cup) |
|
|
| Back to top |
|
 |
nog_lorp Grandmaster Cheater
Reputation: 0
Joined: 26 Feb 2006 Posts: 743
|
Posted: Mon Sep 29, 2008 2:45 pm Post subject: |
|
|
Also, a note:
If you are trying to make the process block, efficiency does not matter. Unless adding a couple bytes to your program's length for the string pushes it beyond the executable size limit or something ridiculous like that.
The real reason not to use system("pause"); is because it is ugly.
~nog_lorp
_________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish |
|
| Back to top |
|
 |
Wintermoot Expert Cheater
Reputation: 0
Joined: 08 Nov 2007 Posts: 198
|
Posted: Tue Sep 30, 2008 9:28 am Post subject: |
|
|
I win now?
My view is that right now, people don't need to be the few milliseconds faster or the few bytes smaller. Yes, size does matter but, only big differences. (Like compiling in Release and not Debug...)
|
|
| Back to top |
|
 |
Nuclear898 Grandmaster Cheater Supreme
Reputation: 0
Joined: 04 Jun 2006 Posts: 1597 Location: The Netherlands
|
Posted: Tue Sep 30, 2008 9:58 am Post subject: |
|
|
Use get
cin.sync()
cin.ignore()
Or else it would take 300mb RAM to run your program...
When you use System("pause") people actually know they have to press a key to continue, unless it's just for testing but you could also print that yourself though...
| Code: | | printf("Press any Key to continue...\n") |
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Tue Sep 30, 2008 11:30 am Post subject: |
|
|
system("pause"); is like using cooking oil to run your car. It might be cheaper and easier to get but it could fuck your car and would probably stink of shit.
You're already using iostream so just use sync() ignore().
|
|
| Back to top |
|
 |
nwongfeiying Grandmaster Cheater
Reputation: 2
Joined: 25 Jun 2007 Posts: 695
|
Posted: Tue Sep 30, 2008 8:34 pm Post subject: |
|
|
| noz3001 wrote: | system("pause"); is like using cooking oil to run your car. It might be cheaper and easier to get but it could fuck your car and would probably stink of shit.
You're already using iostream so just use sync() ignore(). |
That's a nice analogy; never would of thought of it like that.
|
|
| Back to top |
|
 |
Chidori Grandmaster Cheater
Reputation: 1
Joined: 25 Apr 2008 Posts: 691 Location: Canada
|
Posted: Wed Oct 01, 2008 5:30 pm Post subject: |
|
|
| waxxup wrote: | | slovach wrote: | cin.sync()
cin.ignore() |
Thank you!!!
And i won't make the common mistake of not putting ";" at the end of lines . | im new at this so the code is // operating with variables
#include <iostream>
using namespace std;
int main ()
{
// declaring variables:
int a, b;
int result;
// process:
a = 5;
b = 2;
a = a + 1;
result = a - b;
// print out the result:
cout << result;
// terminate the program:
return 0;
}
where do i put in the cync thingy,that pauses the program
|
|
| Back to top |
|
 |
scuba111223 Master Cheater
Reputation: 0
Joined: 10 Sep 2008 Posts: 275
|
Posted: Wed Oct 01, 2008 7:39 pm Post subject: |
|
|
im pretty sure they go right above return 0;
//terminate the program:
cin.sync();
cin.ignore();
return 0;
}
i think its suppose to look like that
|
|
| Back to top |
|
 |
|