Noob here, dont understand why my code does this..

When I run this program, on the surface everything seems fine. But when i type in multiple words, like 'hello there' it will do it twice. So if I space things each string (i guess) will generate its own little question and answer.. Sorry it's really hard for me to explain, but I'm sure you guys know what you're doing. :D
P.S This code is making fun of a close friend, I don't mean to offend. It seems pretty sloppy as well, sorry about that.

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
  #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <stdio.h>
using namespace std;
  
int main(int nNumberofArgs, char* pszArgs[])
{     
    repeatme:
    cout << "------------------------------------------------------------------------\n"; 
    cout << "Is Kindle a homosexual? Please, tell my how you really feel. 'yes', or 'no'.\n";
    string choice;
    cin >> choice;
    if (choice == "yes" || choice == "Yes")
    {
                       cout << "Yes he is quite the homosexual, isn't he?\n";
                       repeat:
                       cout << "Would you like to try again?:";
                       string yesChoice;
                       cin >> yesChoice;
                       if (yesChoice == "yes" || yesChoice == "Yes")
                       {
                                     goto repeatme;
                       }
                       else
                       {
                                     if (yesChoice == "no" || yesChoice == "No")
                                     {
                                                   cout << "Okay, have a good day then.\n";
                                                   system ("PAUSE");
                                                   return 0;
                                     }
                                     cout << "Error, you did not type 'yes', or 'no'.\n";
                                     goto repeat;
                       }
    }
    else
    {
                       if (choice == "no" || choice == "No")
                       {
                                          cout << "What? you must've typed that wrong. Or you're Kindle. Take your pick.\n";
                                          goto repeat;
                                          
                       }
                       cout << "Please enter a valid answer. A simple 'yes', or 'no' will do. Try again.\n";
                       goto repeatme;
    }   
}
This will read just a single word at a time:
1
2
    string choice;
    cin >> choice;

If you want to input multiple words at one time, use getline
getline(cin, choice);
Ah! It worked! Thank you much sir. :D
Topic archived. No new replies allowed.