cin wont work.

I use Netbeans 6.7.1 in ubuntu 9.1

My code is below... I don't understand why cin doesn't stop for input...

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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
/* 
 * File:   main.cpp
 * Author: joshua
 *
 * Created on January 31, 2010, 5:11 AM
 */

#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <time.h>

void Splash();
void attRoll();
void attSel();
int attPhy, attMen, attSpi, attMag;



using namespace std;


int main() {

    srand(time(NULL)); // sets the random seet to the system time.

    int a;

    /* This is where we roll the attributes one die at a time
     * then adding them together to form each attribute score
     */

    
    Splash();

    cout << "Key in a character name then hit enter to continue.\n\n";

    cin >> a, cout << "\n";

    attSel();

    return (EXIT_SUCCESS);
}

void Splash() { 
    cout << "RandomRPG NPC Statblock Generator ver 0.0.1\n";
    cout << "By: Joshua Farr\n";
    cout << "Developed in c++ using NetBeans IDE\n";
    cout << "Copyright 2010\n\n";
}

void attRoll() {
    int die[12], sum;

    cout << "Rolling Attributes... (12d)\n\n";

    for (int i = 0; i < 12; i++)
    {
       die[i] = rand() % 6 + 1;
        switch (i) {
            case 0:
                
                cout << "Rolling physical...";
                sum=0;
                cout << "die #" << i+1 << " = " << die[i] << ", ";
                sum+=die[i];
                break;

            case 1:
                
                cout << "die #" << i+1 <<  " = " << die[i] << ", ", sum+=die[i];
                break;

            case 2:

                sum+=die[i], attPhy = sum;
                cout << "die #" << i+1 << " = " << die[i];
                cout << "... Physical: " << attPhy << endl;
                break;

            case 3:

                cout << "Rolling mental...";
                sum = 0;
                cout << "die #" << i+1 << " = " << die[i] << ", ";
                sum+=die[i];
                break;

            case 4:

                cout << "die #" << i+1 << " = " << die[i] << ", ", sum+=die[i];
                break;

            case 5:

                sum+=die[i], attMen = sum;
                cout << "die #" << i+1 << " = " << die[i];
                cout << "... Mental: " << attMen << endl;
                break;

            case 6:
                      
                cout << "Rolling spiritual...";
                sum = 0;
                cout << "die #" << i+1 << " = " << die[i] << ", ";
                sum+=die[i];
                break;

            case 7:

                cout << "die #" << i+1 << " = " << die[i] << ", ", sum+=die[i];
                break;

            case 8:

                sum+=die[i], attMen = sum;
                cout << "die #" << i+1 << " = " << die[i];
                cout << "... Spiritual: " << attMen << endl;
                break;

            case 9:

                cout << "Rolling magical...";
                sum = 0;
                cout << "die #" << i+1 << " = " << die[i] << ", ";
                sum+=die[i];
                break;

            case 10:

                cout << "die #" << i+1 << " = " << die[i] << ", ", sum+=die[i];
                break;

            case 11:

                sum+=die[i], attMen = sum;
                cout << "die #" << i+1 << " = " << die[i];
                cout << "... Magical: " << attMen << endl << endl;
                break;
        }
                
                   


    }
}

void attSel(){

    int a=0;

    cout << "Do you want to roll the attributes or have them generated?\n\n";

    cout << "  1. Roll Manually\n  2. Generate\n\n";

    cin >> a; //Why wont this stop to request input?

    if (a==1)
        //some option...;
    {
        cout << "Enter you score for Physical: ";
        cin >> a;
        cout << a;
    }
    else if (a==2)
        attRoll();

    else
        cout << "Bad Input!\n\n";

}
The statement on line 38 makes no sense. What are you trying to do?
It is just meant to rec a character name for now. The line I am having trouble with is line 156... why wont it stop to rec input like all the other instances of cin?
Topic archived. No new replies allowed.