There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
C++ problem


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
nexu251's Avatar
Junior Member with 2 posts.
 
Join Date: Oct 2005
Experience: Beginner
29-Oct-2005, 05:21 PM #1
C++ problem
alrite im kinda new to C++ and im starting to write small games and when i made my menu script it started good where you had to enter the number to which level of difficulty you want then when u put in the number and hit enter it runs through the rest of the script super fast and exits the screen so can i get some help here heres the script



Code:
Code: 
 

// Menu Chooser 
// Demonstrates the switch statement 
 
#include <iostream> 
using namespace std; 
 
int main()  
{ 
      cout << "Difficulty Levels\n\n"; 
      cout << "1 - Easy\n"; 
      cout << "2 - Normal\n"; 
      cout << "3 - Hard\n\n"; 
 
      int choice; 
      cout << "Choice: "; 
      cin >> choice; 
 
      switch (choice) 
      { 
      case 1:       
                  cout << "You picked Easy.\n"; 
                  break; 
      case 2:       
                  cout << "You picked Normal.\n"; 
                  break; 
      case 3:       
                  cout << "You picked Hard.\n"; 
                  break; 
      default: 
                  cout << "You made an illegal choice.\n"; 
      } 
 
    return 0; 
} 
Code:

ok this is it so far but then i thought it would work if i did this

Code:
Code: 
 

// Menu Chooser 
// Demonstrates the switch statement 
 
#include <iostream> 
using namespace std; 
 
int main()  
{ 
      cout << "Difficulty Levels\n\n"; 
      cout << "1 - Easy\n"; 
      cout << "2 - Normal\n"; 
      cout << "3 - Hard\n\n"; 
 
      int choice; 
      cout << "Choice: "; 
      cin >> choice; 
 
      switch (choice) 
      { 
      case 1:       
                  cout << "You picked Easy.\n"; 
                  break; 
      case 2:       
                  cout << "You picked Normal.\n"; 
                  break; 
      case 3:       
                  cout << "You picked Hard.\n"; 
                  break; 
      default: 
                  cout << "You made an illegal choice.\n"; 
      } 
    std::cout << "press the enter key to exit"; 
    std::cin.ignore(std::cin.rdbuf()->in_avail() +1); 
    return 0; 
} 
Code:
but it didnt so does anyone know how to stop this thanks
aewarnick's Avatar
Senior Member with 839 posts.
 
Join Date: Sep 2002
30-Oct-2005, 06:18 PM #2
Programming uses loops to keep any application running. Look at the console programs on my site:

http://foryouandi.com/Programs/index.php
Download IntToStr.
nexu251's Avatar
Junior Member with 2 posts.
 
Join Date: Oct 2005
Experience: Beginner
31-Oct-2005, 03:33 PM #3
i got it now im just useing

system("PAUSE");
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 10:30 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.