Setting variables using if/else statements

I'm trying to write an interactive story, setting the main character's gender as a variable so that the proper pronouns will be used. I'm taking an introductory C++ class, so I probably have some things wrong. I'm getting an undeclared identifier error on lines 17 - 22, 27 - 32 and 42 and 43. Doesn't line 13 take care of 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
   #include <iostream>
   using namespace std;

   int main()
   {
    cout << "\tWelcome!\n";
	int gender;
	cout << "Are you male or female?\n";
	cout << "1 - Male\n";
	cout << "2 - Female\n";
	cin >> gender;

	char he_she, He_She, him_her, Him_Her, his_hers, His_Hers;

	   if (gender == 1)
	   {
		he_she = he;
		He_She = He;
		him_her = him;
		Him_Her = Him;
		his_hers = his;
		His_Hers = His;
	   }

	   else
	   {
		he_she = she;
		He_She = She;
		him_her = her;
		Him_Her = Her;
		his_hers = hers;
		His_Hers = Hers;
	   }

    char userName[100];
    cout << "\nPlease enter your character's name: ";
    cin >> userName;
    cout << "Hello, " << userName << "!\n\n";

	//Gender test
        cout << "Gender Test\n";
        cout << he_she << " " << He_She << " " << him_her << endl;
        cout << Him_Her << " " << his_hers << " " << His_Hers << endl;

   return 0
   }
Last edited on
'he', 'He', 'him', 'Him', 'his', 'His', 'she', 'She', 'her', 'Her', 'hers', and 'Hers' are undefined.
You must have meant to make them strings, which would be "he", "He", etc.
'char' can't hold strings, but 'char *' and str::string can.
I'll save you posting in an hour or two about why cin >> meh; isn't working properly for you.

Read:
http://www.cplusplus.com/forum/articles/6046/
Topic archived. No new replies allowed.