* Don't use system("pause") to pause your program if possible. Use getchar( ) if you are using C and cin.get( ) if you are using C++. Why is that? A reasonable explanations for those tips would help to learn.

getchar()-it shows the character to be displayed on screen. Where else getch() gives the character but doesn't display on the screen.

getchar()-it shows the character to be displayed on screen. Where else getch() gives the character but doesn't display on the screen.

Yes but, why don't use system("pause") at all? I mean what's wrong with it?

Yes but, why don't use system("pause") at all? I mean what's wrong with it?

http://cboard.cprogramming.com/c-programming/56441-can-someone-help-me-understand-example-program.html#post394525

>system("pause");
This is all kinds of wrong. First, while system is a standard function and thus portable, the argument you pass to it cannot be portable because it relies on the system command interpreter. If you move the code to a different system, the command interpreter will probably be different (or not available!) and system("pause") could do something completely different or break.

Second, system is unsafe because it doesn't verify that the pause program is the one supplied by the system. It may be a malicious program bent on wreaking havoc.

Third, system is sloooooooow. Dreadfully, painfully, agonizingly sloooooooow. This isn't really a problem if you call it once, like here, but system should really be avoided in favor of better alternatives. My code shows one of those alternatives. It requires the user to hit return, but it's portable and does the job admirably with no noticeable inconvenience to the user.

Although i'm using it only to avoid the cmd from closing without getting a chance to glance the outpot, that was a nice explanation and very usefull.

Thanks a lot!

* Don't use system("pause") to pause your program if possible. Use getchar( ) if you are using C and cin.get( ) if you are using C++. Why is that? A reasonable explanations for those tips would help to learn.

Yes but, why don't use system("pause") at all? I mean what's wrong with it?

http://www.gidnetwork.com/b-61.html

On Windows, system() is prohibited by MS.
It's dirty, it creates another useless PAS, etc...

commented: Hai marco93, now a couple of post back I gave you +rep by accident. So this is me correcting my mistake. Salut! -2
commented: You're just extremely useless. -1
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.