Dos help.

This is a discussion on Dos help. within the C++ Programming forums, part of the General Programming Boards category; Code: #include <iostream.h> int main() //Most important part of the program! { int age; //Need a variable... cout<<"Please input your ...

  1. #1
    Registered User
    Join Date
    Dec 2003
    Posts
    2

    Dos help.

    Code:
    #include <iostream.h>			
    int main()				//Most important part of the program!
    {
      int age;				//Need a variable...
      cout<<"Please input your age: ";	//Asks for age
      cin>>age;				//The input is put in age
      if(age<100)				//If the age is less than 100
      {
         cout<<"You are pretty young!";     //Just to show it works
      }
      else if(age==100)		//I use else just to show an example 
      {
         cout<<"You are old";		//Just to show you it works...
      }
      else
      {
        cout<<"You are really old";	//Executed if no other statement is executed
      }
      return 0;
    }
    For some reason, my dos prompt closes after its done with the results, i dont have XP so i cant just right click on the program and go to "program" tab.

    Also someone said to place cint>>whatever ?? Since im new at this, i dunno what he's talking about, i just want the dos screen to stay so i can see results in the .exe

    Also,going to properties in the dos screen doesnt help, i unchecked the thing that said "close when exit" or something, it still closes after it runs. Any help?

    (this is in the tutorials at cprogramming.com btw, the second tutorial.)

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    FAQ
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Dec 2003
    Posts
    101
    It's supposed to do that, put 'cin>>age;' at the end. Theirs a getches or something where you make a loop 'while(getch!=1);' or something that will wait for user input but I don't know the exact source. Maby someone else does(hint ..hint)

    Edit: I found it: from cpp-home
    Last edited by 1veedo; 12-07-2003 at 07:03 PM.
    --

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File systems?? (Winxp -> DOS)
    By Shadow in forum Tech Board
    Replies: 4
    Last Post: 01-06-2003, 08:08 PM
  2. winver, winminor, winmajor can it be found from dos?
    By ronin in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 10-02-2002, 10:32 AM
  3. real mode dos & win dos
    By scott27349 in forum A Brief History of Cprogramming.com
    Replies: 26
    Last Post: 08-19-2002, 06:15 AM
  4. DOS program versus DOS console program
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2002, 12:42 PM
  5. Shut off DOS screen automatically to Windows
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 11-08-2001, 06:14 PM

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