Beginners Problem while Learning C++

Discussion in 'Programmer's Corner' started by sailmike, Aug 11, 2015.

  1. sailmike

    Thread Starter Member

    Nov 11, 2013
    143
    3
    I'm teaching myself C++ programming from the book "Jumping Into C++". It's a great book so far and makes it easy to learn the language. I'm using Microsoft Visual Studio as the compiler. When I run a simple code the window doesn't stay open long enough for me to read the results. I tried the cin.get(); command, but that didn't work. I've attached the simple code in hopes one of you may recognize a mistake. I was using Code::Blocks through the first 2 chapters, but the program then tried installing malware on my PC, so I deleted that software and went with Microsoft Visual Studio.

    Thank you,
    Mike Jumping Into C++ Problem.jpg Jumping Into C++ Problem 2.jpg
     
    RRITESH KAKKAR likes this.
  2. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    Try
    Code (C++):
    1. system("pause");
    or
    Code (C++):
    1.  
    2. #include<stdio.h>
    3. // ...
    4. getchar();
    5.  
     
  3. sailmike

    Thread Starter Member

    Nov 11, 2013
    143
    3
    You first suggestion worked.

    Thanks!
     
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,386
    1,605
    Just open a dos box and run your program from there.

    That window stays open until you choose to close it.
     
  5. Cornel Ionut Vida

    New Member

    Nov 24, 2015
    1
    0
    In Visual Studio, you can add break points at lines of execution.

    Add one at the last bracket "}" and it will stop there after running the program in debug mode.
     
  6. RRITESH KAKKAR

    Senior Member

    Jun 29, 2010
    2,831
    89
    In college i have also studied little bit C++
    remember only Cout<<
     
Loading...