Not going for an input

This code:

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
void unosKonacnog(bool *tacanOdgovor, string asocijacija[], string prikazA[], string prikazB[], string prikazC[], string prikazD[], string prikazKonacnog){
    char izbor;
    string odgovor;
    cout << "Unesite koje konacno pogadjate : A, B, C, D, K, N" << endl;
    cin >> izbor;
    switch(izbor){
        case 'A': {
            cout << "Unesite konacno resenje kolone A: ";
            getline(cin, odgovor);
            if(odgovor==asocijacija[4]) prikazA[4]=asocijacija[4];
        }break;
        case 'B': {
            cout << "Unesite konacno resenje kolone B: ";
            getline(cin, odgovor);
            if(odgovor==asocijacija[9]) prikazA[4]=asocijacija[9];
        }break;
        case 'C': {
            cout << "Unesite konacno resenje kolone C: ";
            getline(cin, odgovor);
            if(odgovor==asocijacija[14]) prikazC[4]=asocijacija[14];
        }break;
        case 'D': {
            cout << "Unesite konacno resenje kolone D: ";
            getline(cin, odgovor);
            if(odgovor==asocijacija[19]) prikazD[4]=asocijacija[19];
        }break;
        case 'K': {
            cout << "Unesite konacno resenje cele asocijacije: ";
            getline(cin, odgovor);
            if(odgovor==asocijacija[20]) prikazKonacnog=asocijacija[20];
            *tacanOdgovor=true;
        }break;
    }

}


should first ask for an input of one char (A,B,C,D or K). After that its supposted to for for an second input, this time of string (answer of one question) but it doesnt, it goes straight thro it and goes to the next step (next function in main) but it does cout message. What could it be wrong? Does anyone see what i cant? xd

thanks
Last edited on
If you want multiple inputs, one after another, then you will need some kind of loop. Are you familiar with for/while loops?

If just need a char input followed by another string input in this function then simply call cin >> answer where type of answer should be either char * (allocated before cin of course) or std::string
Im using while loop in the main, and it works as it should but my problem is that somehow, input in that switch (showed upper) is skipped. It gives me cout in console but doesnt allow me to input string "odgovor" (stands for an answer in my lang.). I think i cant use cin for input string and i tried with any god damn input function and it doesnt work? xd

Topic archived. No new replies allowed.