I've read that one should use cin.get() instead of system("pause"). Why is that?
Azurea
0
Light Poster
Recommended Answers
Jump to Post1) system("pause") is not portable -- only works on MS-Windows and MS-DOS operating systems.
2) cin.get() is a lot faster
Jump to Post
system("pause")
represents an unsafe programming practice. Not only is the argument to the system function non-portable (your code would work on Windows but not Linux, for example), someone could replace the "pause" program on the machine with a malicious program and use it to cause trouble. Spoofing a legitimate …
Jump to PostSpoofing a legitimate program is a common practice among malware
yeah, i heard about thinks like that. e.g people replacing "ls" in linux with a command to recurisvely delete all directories. Will teach you to run as root ;)
Jump to PostIt depends on what preceeded the cin.get().
All 16 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
Narue
5,707
Bad Cop
Team Colleague
jbennet
1,618
Most Valuable Poster
Team Colleague
Featured Poster
Azurea
0
Light Poster
sgw
0
Junior Poster in Training
Azurea
0
Light Poster
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
sgw
0
Junior Poster in Training
Dave Sinkula
2,398
long time no c
Team Colleague
sgw
0
Junior Poster in Training
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
sgw
0
Junior Poster in Training
Dave Sinkula
2,398
long time no c
Team Colleague
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
ikbendeman
0
Newbie Poster
WaltP
2,905
Posting Sage w/ dash of thyme
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.