Dev-C++, Only One Input...

Hey forum, I'm having a problem with my program. I can't seem to enter more than one command and then I'm forced to close my program. For example, when I assign a value to a variable and press enter it goes through, but then when I try to perform another action the window closes... any hot fixes?

Thanks,
Xitan
Last edited on
What is your code?

- Also : Change your IDE, Dev-C++ is outdated http://www.cplusplus.com/forum/articles/7263/ -
Well to start I would like to tell you there isn't much help to be offered unless you submit your code for that piece of your program.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
include <iostream>

int main()
{
    using std::cin;
    using std::cout;
    using std::endl;
    
    cout << "\nWELCOME TO COUNTER STRIKE: CMD TASK FORCE!" << endl;
    cout << "\n\nWhat would you like to do? Select one of the options below; \nenter the numberthat represents the option:\n===========================================================\n";
    
    int goption;
     
    cout 
    << "1) Start Game..." 
    << endl 
    << "2) How to Play..." 
    << endl 
    << "3) About..." 
    << endl 
    << "4) Exit." 
    << '\n';
    
    cin >> goption;
    cin.ignore();
    
    if (goption == 1) {
           cout << "You are equipped with armor and a weapon." // String continues...
            "Your team has fallen and you're the only survivng member." // String continues...
            "There are three enemys left, and how you fight will ultimately" // String continues...
            "lead to whether you're victorious or your mission was a failure." // String continues...
            "How do you want to proceed?"; // String ends.    
          
          } else { goption >= 5; }
                 
    if (goption == 2) {
           cout << "Simply enter options as you make your way through the game.";
           } else { goption >= 5; }
                  
    
    if (goption == 3) {
           cout << "Counter Strike: CMD Task Force was written by Weston Soden." 
                    "The program is a simple game that asks for the users input" 
                    "throughout the game, though it is not very complex, it is" 
                    " still very fun.";
           } else { goption >= 5; }
           
    if (goption == 4) {
                cout << "Press the \"ENTER\" key to exit:"; }
    
    if (goption <= 0) {
                cout << "Please enter a valid option."; }
    
    if (goption >= 5) {
           cout << "Plese enter a valid option."; }
           
    
                  
                  
           
           
    cin.get();
    std::cin.ignore( std::numeric_limits<std::streamsize>::max(), '\n' );
    return (0);
}


Sorry about the title, was a dumb idea i got in my head.
Last edited on
What are you doing on lines 34, 38 and 46 with goption >= 5?
Last edited on
For example, when I assign a value to a variable and press enter it goes through, but then when I try to perform another action the window closes...
Can you elaborate that? You are reading input only once in your program so it does what it should.
I know for starters you need a pound symbol (#) in front of your include at the beginning.
His cin.get(); command accepts a second input which puts on the illusion of another variable input and then proceeds to closing the program.
Topic archived. No new replies allowed.