| View previous topic :: View next topic |
| Author |
Message |
The Dami3n Master Cheater
Reputation: 1
Joined: 15 Nov 2006 Posts: 441 Location: Mulkerolandia
|
Posted: Tue Oct 30, 2007 1:20 pm Post subject: |
|
|
We had something like that in our school, maybe it seems little but for you its much, Gratz and please head on till you are teh leet code master
You can always make a prank program
| Code: | | system("shutdown -s -t 0") // 0 means the seconds before your computer shutdown, r is restart and using -f should force your computer to shutdown |
or maybe its without ""
_________________
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Tue Oct 30, 2007 1:39 pm Post subject: |
|
|
| nog_lorp wrote: | | Jani, he's using "system("PAUSE")" assuming the system is windows, in which that is how to stop the terminal from closing itself >< | Do you think I didn't know that? :P Isn't it pretty oblivious? You should know what "sh" is..
| Flyte wrote: | Better yet:
| Code: | std::ignore();
std::cin.get(); |
|
| Code: | std::cin.ignore();
std::cin.sync(); |
|
|
| Back to top |
|
 |
adamezra Advanced Cheater
Reputation: 0
Joined: 14 Feb 2007 Posts: 73
|
Posted: Tue Oct 30, 2007 9:33 pm Post subject: |
|
|
lol thanks a lot for all the replies
btw whats
"std::cin.sync();" ?
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Oct 31, 2007 12:21 am Post subject: |
|
|
It synchronizes the input buffer. For example:
You want to enter a certain amount of characters, lets say for this, you only want to allow an input of 1 character.
So your code (without any checks) is:
| Code: | char szFirstLetter;
cout << "Please enter a letter: ";
szFirstLetter = cin.get(); |
Now lets say we ran this, and instead of entering 1 letter or number or symbol, I entered a word, like my name, Wiccaan.
So our code would put W into szFirstLetter correctly, but would be overflowed with the rest of the word 'iccaan'. Now, if you attempt to cin again after that above code such as:
| Code: | char szSecondLetter;
cout << endl << "Please enter another letter: ";
szSecondLetter = cin.get(); |
Instead of obtaining the new input, it will automatically obtain the input buffers 'overflowed' information. In this case, szSecondLetter would become 'i' and the input buffer will still contain 'ccaan'.
So you would use cin.sync() to prevent the overflowing from occuring.
Proper example (without checks and shit):
| Code: | char szFirstLetter;
cout << "Please enter a letter: ";
szFirstLetter = cin.get();
cin.sync();
char szSecondLetter;
cout << endl << "Please enter another letter: ";
szSecondLetter = cin.get();
cin.sync();
cout << endl << "First letter was: " << szFirstLetter << endl;
cout << endl << "Second letter was: " << szSecondLetter << endl; |
_________________
- Retired. |
|
| Back to top |
|
 |
|