code help

This is a discussion on code help within the C++ Programming forums, part of the General Programming Boards category; ok here is the code #include <iostream.h> int main() { int thisisanumber; cout<<"Please enter a number:"; cin>>thisisanumber; cout<<"You entered: "<<thisisanumber; ...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    176

    Question code help

    ok here is the code
    #include <iostream.h>

    int main()

    {

    int thisisanumber;

    cout<<"Please enter a number:";

    cin>>thisisanumber;

    cout<<"You entered: "<<thisisanumber;

    return 0;

    }
    and i have dev-c++ version 4.9.8.0
    it compiles fine but when i try and run it it says please enter a number and when you do and hit enter the whole box disappears

  2. #2
    Funniest man in this seat minesweeper's Avatar
    Join Date
    Mar 2002
    Posts
    801
    Yeah the programs that dev-c++ makes will do that. They exit straight away and your program is running too fast for you to see anything.

    The simplest thing for you to do is probably put another,

    Code:
    cin>>thisisanumber;
    immediately before your return statement.

    That way the program will wait for you to enter another number before continuing.

  3. #3
    Registered User axon's Avatar
    Join Date
    Feb 2003
    Location
    Mt. Prospect, IL
    Posts
    2,572
    or, if dev includes it (sorry I'm not familiar) use Sleep before return statement,

    Code:
    Sleep(1000);
    This is explained in detail in the FAQ on this board

    axon

    some entropy with that sink? entropysink.com

    there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Extended ASCII Characters in an RTF Control
    By JustMax in forum C Programming
    Replies: 18
    Last Post: 04-03-2009, 08:20 PM
  2. Enforcing Machine Code Restrictions?
    By SMurf in forum Tech Board
    Replies: 21
    Last Post: 03-30-2009, 07:34 AM
  3. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 03:17 PM
  4. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM
  5. Replies: 0
    Last Post: 02-21-2002, 05:05 PM

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