|
||||
|
« Things to Avoid in C/C++ -- feof(), Part 3 | Things to Avoid in C/C++ -- scanf, Part 5 » |
Things to Avoid in C/C++ -- system("pause"), Part 4
by: WaltP - Sep 20, 2005
system("pause")I've never understood why system("PAUSE") is so popular. Sure it will pause a program before it exits. This pause is very useful when your IDE won't wait as you test a program and as soon as the program finished the window closes taking all your data with it. But using system("PAUSE") is like burning your furniture for heat when you have a perfectly good thermostat on the wall. Many people, instructors included, for some inexplicable reason think that making a call to the operating system and running a system command to temporarily halt a program is a good thing. Where they get this idea is beyond me. Reasons:
It's a bad habit you'll have to break eventually anyway. Instead, use the functions that are defined natively in C/C++ already. So what is it you're trying to do? Wait for a key to be pressed? Fine -- that's called input. So in C, use getchar() instead. In C++, how about cin.get()? All you have to do is press RETURN and your program continues.
|
GIDNetwork Sites
Archives
Recent GIDBlog Posts
Recent GIDForums Posts
Contact Us
|
« Things to Avoid in C/C++ -- feof(), Part 3 | Things to Avoid in C/C++ -- scanf, Part 5 » |