is system("PAUSE") required in every program?

This is a discussion on is system("PAUSE") required in every program? within the C++ Programming forums, part of the General Programming Boards category; is it?what really happens if you dont put system("PAUSE")?i heard that if you enter it,then you wont be able to ...

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    5

    Question is system("PAUSE") required in every program?

    is it?what really happens if you dont put system("PAUSE")?i heard that if you enter it,then you wont be able to print the output and all...

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,326
    It is not required at all.
    • There are (more or less) substitutes for it, some of which are more portable as well.
    • You can just run your program via the command line/prompt, as you should do in the first place.
    • The need for it disappears if your program is not even meant to be run from the command line/prompt.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Sep 2008
    Posts
    5
    oh thanks!Actually i am new to C++ programming.i am a student,and we have a test tomorrow.The examiner cuts marks if you dont put in system("PAUSE")

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,326
    Well, if the examiner insists, then go ahead and do so, but note that the examiner is misguided.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Sep 2008
    Posts
    5
    thanks.Also,what is the difference between the post-increment and pre-increment operator?We were told its the same thing but i have a doubt.....

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,414
    int n = 10;
    int x = n++;
    cout << x; // Prints 10
    cout << n; // Prints 11
    x = ++n;
    cout << x; // Prints 12
    cout << n; // Prints 12

    That should answer your question.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,326
    Also,what is the difference between the post-increment and pre-increment operator?
    A quick search of the Web reveals Difference between pre-increment and post-increment.

    We were told its the same thing but i have a doubt.....
    In that case I must advise you that your teachers are not just misguided, but terribly ignorant, possibly even incompetent. If this is a private course, you would be better off dropping it.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    Registered User
    Join Date
    Sep 2008
    Posts
    5
    its a subject in school.And the teacher comes for half an hour one day before the exam and completes the course.If it isnt completed,then its self study.Thats the case this time,so that is exactly why im sitting online surfing tutorials.

  9. #9
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,625
    In English, post-increment makes a copy of the object with the old value, does the operation, and returns the copy. Pre-increment simply does the operation and returns a reference to the object. So it depends entirely on whether you need the initial value, most of the time. If copying the object is a performance bottleneck, than you know what to avoid...

  10. #10
    Registered User
    Join Date
    Sep 2008
    Posts
    5
    oh.
    what are logical operators?

  11. #11
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,326
    We actually have a tutorial section on this site. It is not much, some of it is outdated, but at least it is something. In particular, check out the tutorial on if statements. At the bottom it has something to say about the logical operators (or what it calls boolean operators).
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  12. #12
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Quote Originally Posted by Elysia View Post
    int n = 10;
    int x = n++;
    cout << x; // Prints 10
    cout << n; // Prints 11
    x = ++n;
    cout << x; // Prints 12
    cout << n; // Prints 12

    That should answer your question.
    That does not demonstrate the difference between post-increment and pre-increment operators.

  13. #13
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by robwhit View Post
    That does not demonstrate the difference between post-increment and pre-increment operators.
    Why doesn't it?

  14. #14
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Oh wait it does. LOLtomyself

  15. #15
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Quote Originally Posted by xstarburstbaby View Post
    oh thanks!Actually i am new to C++ programming.i am a student,and we have a test tomorrow.The examiner cuts marks if you dont put in system("PAUSE")
    I bet what the examiner is actually requring is that there are pauses in the execution of your code, more so than actually using system("PAUSE"). I betcha I can hack into your computer if you keep using that, and I am not turning to the dark side on anyone here... I am simply pointing out that your programs have an easily exploited security breach in them. Several times per execution, in fact.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie needs help..
    By xpress urself in forum C++ Programming
    Replies: 3
    Last Post: 07-26-2007, 07:22 PM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 10:17 PM
  4. I need some help with my program please.
    By agentxx04 in forum C Programming
    Replies: 9
    Last Post: 09-26-2004, 07:51 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 10:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21