C++ Question

Discussion in 'OT Technology' started by nucklearknight, Oct 9, 2008.

  1. nucklearknight

    nucklearknight New Member

    Joined:
    Sep 21, 2008
    Messages:
    367
    Likes Received:
    0
    Location:
    San Francisco, California
    I'm slowly teaching myself C++ and I'm writing a little quiz program. However I have read somewhere that the codes
    Code:
    system("cls")
    
    system("pause")
    
    exit(0)
    are inefficient. Why is that and what are alternatives?
     
  2. CodeX

    CodeX Guest

    doesn't really matter if exit is inefficient lol.

    system calls are cop-outs in my opinion... who writes console apps for DOS anymore though?

    The real answer is... it doesn't matter. If you are using any of those functions your program is so trivial efficiency is of no concern.
     
  3. ge0

    ge0 New Member

    Joined:
    Oct 31, 2005
    Messages:
    8,398
    Likes Received:
    0
    Location:
    JERSEY
    lol clear screen and pasue? wtf..... why not use sleep?
     
  4. nucklearknight

    nucklearknight New Member

    Joined:
    Sep 21, 2008
    Messages:
    367
    Likes Received:
    0
    Location:
    San Francisco, California
    Sleep?
     
  5. ge0

    ge0 New Member

    Joined:
    Oct 31, 2005
    Messages:
    8,398
    Likes Received:
    0
    Location:
    JERSEY
    sleep()
     
  6. nucklearknight

    nucklearknight New Member

    Joined:
    Sep 21, 2008
    Messages:
    367
    Likes Received:
    0
    Location:
    San Francisco, California
    I didn't know about that function. Thanks.
    I just read about it and I now know it will pause a program but does it also clear the screen?
     
  7. quzer

    quzer New Member

    Joined:
    Nov 9, 2003
    Messages:
    206
    Likes Received:
    0
  8. CodeX

    CodeX Guest

  9. nucklearknight

    nucklearknight New Member

    Joined:
    Sep 21, 2008
    Messages:
    367
    Likes Received:
    0
    Location:
    San Francisco, California
    So learning C++ is a useless endeavor that I should give up on immediately?
     
  10. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    No, but you should also learn how to build GUIs for your apps.
     
  11. CodeX

    CodeX Guest

    No, I am just being cynical, while learning the language what you are doing is fine. I am just saying discussing it is rather trivial because the ONLY programs that use the dos prompt for IO anymore are ones written by students learning the language, like you.

    Later, after you get a good grasp of C++ you can make normal windows applications if you so choose, complete with graphics and animations and buttons and menus and text fields and file open/save dialog boxes etc etc just like any other windows program.
     
  12. nucklearknight

    nucklearknight New Member

    Joined:
    Sep 21, 2008
    Messages:
    367
    Likes Received:
    0
    Location:
    San Francisco, California
    How would I do that?
     
  13. CodeX

    CodeX Guest

    Read up on the windows API if you want to go with C++, its more difficult but more powerful. You can always use .NET in VB or C#, which is more like using a toolkit built by someone else, which is good for banging out fast generic apps.
     
  14. nucklearknight

    nucklearknight New Member

    Joined:
    Sep 21, 2008
    Messages:
    367
    Likes Received:
    0
    Location:
    San Francisco, California
    Cool thanks, I'll look into that!
    :big grin:
     
  15. deusexaethera

    deusexaethera OT Supporter

    Joined:
    Jan 27, 2005
    Messages:
    19,712
    Likes Received:
    0
    Visual Studio 2008 Express Editions are free to download from www.microsoft.com.
     
  16. quzer

    quzer New Member

    Joined:
    Nov 9, 2003
    Messages:
    206
    Likes Received:
    0
    I'd recommend learning GUI in like Java or something, the Windows API is specific to windows, it won't work on a Mac or any UNIX based distro, however, I'm not saying that you shouldn't learn the Windows API at some point though.
     
  17. CodeX

    CodeX Guest

    I would highly recommend against doing anything graphical in java. It is dog slow, it looks like shit unless you really get into customizing it, and what you will learn from it is mostly useless because it has an ass-backward way of doing everything.

    I want to make this perfectly clear. I never suggested that you start writing graphical programs right now. If you are new to C++ the LAST thing you want to do is get mired down in API code. Learn the basics first, and using the DOS command prompt for IO is just fine while you are learning. When and if you want to learn Windows GUI the MSDN library is the most important thing you will ever read. I can also upload the source of some of my own programs, including a full featured MP3 player as well as the games found here: www.codextreme.net
     
    Last edited by a moderator: Oct 15, 2008

Share This Page