Jump to content

C++ newbie.

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
7 replies to this topic

#1
Rockoff

Rockoff

    Newbie

  • Members
  • Pip
  • 2 posts
Hey guys, I'm starting to learn C++ using "C++ Programming for the Absolute Beginner" (not pirated, I swear >.>) but I don't know anybody that can code in C or C++ so I'm wondering if anyone here would like to help me learn (by adding me on msn and answering the occasional quick question or giving me a few tips). I can't post emails yet but I will when I have a few more posts.

Also, I'd appreciate any tips on learning a new programming language that you'd like to give to make the process a little easier.

The questions will be like "How do I use cin to stop my program exiting automatically after it finishes doing its thing not allowing me to view my work?" (I'd appreciate an answer to that one asap actually xP).

Any help is appreciated and I'm glad to be a part of your wonderful community.

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Just ask your questions here, and we'll attempt to answer them.

At the end of main(), before your return statement, just add "cin>>myint;"
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
theonejb

theonejb

    Learning Programmer

  • Members
  • PipPipPip
  • 52 posts
cin.get() might be better...

#4
LogicKills

LogicKills

    Programmer

  • Members
  • PipPipPipPip
  • 139 posts
The best way to learn a programming language (just like most other things) is practice. You have to make sure that you are constantly programming new things. You also have the be determined enough to be able to keep going even when your code doesn't compile.

A fun way to get fairly good at programming is working on open source projects. It is only fun if you enjoy the project. You can start small by finding bugs and trying to figure out what can be done to fix. Eventually you will actual submit your own patches.

If you enjoy programming and know a bit but want to learn. Myself and a buddy work on an open source keylogger. It's on SourceForge under "myHook". Pretty good code base so far.

Good luck!
http://logickills.org
Science - Math - Hacking - Tech

#5
Stargate476

Stargate476

    Newbie

  • Members
  • Pip
  • 2 posts
I am kind of new to c++. I am curious other then system pause because that obviously isnt the best method of stopping the console program from what I hear. So how does the other methods work because I have yet to figure them out. Running the program within the ide i use keeps it open but outside it closes too fast.

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
The goal is to ask for input to keep it from closing. The best suggestion, for my money, is to simply launch the program from the command line, not the IDE. That way, you can see the output after the program closes.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
TkTech

TkTech

    The Crazy One

  • Moderators
  • 1,396 posts
If you're using VC++, try this.

#if defined(_DEBUG)
    std::cin.get();
#endif

At the end of your program. This will cause it to stop and wait for the <enter> key before continuing. Checking for _DEBUG means it will only be compiled in when you run it via F5.

#8
Stargate476

Stargate476

    Newbie

  • Members
  • Pip
  • 2 posts
Well if i just put cin.get() or cin.ignore twice at the end of my program it stops it. Was playing with one of my programs last night and figured it out. The ide i use is codeblocks mainly.