So Confused - Help plox?

Pages: 12
I did not know that. I guess you learn something new everyday.
Here is the whole thing - thanks for all the replys!

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
#include <iostream>
#include <conio.h>
#include <cstdlib>
#include <string>
#include <windows.h>

using namespace std;

int main()
{
    
    char b, d;
    char item_type;
    int s;
    int amount;
    int inventory[10]; 
    
    loop15:                                                                   // shop loop
    cout << "\n\n1)General Store          5)Bar";
    cout << "\n2)Blacksmith             6)Joe's House";
    cout << "\n3)Potions/Magic Shop";
    cout << "\n4)Weapons";
    s = getch();               // goes into stores/back to menu of stores to purchase items
      switch (s) {
             case '1':
                  cout << "\n\nWelcome To The General store!\n";
                  cout << "1) 1 Gallon Water:" << endl; 
                  cout << "2) 1 lb Meat:" << endl;
                  cout << "3) 5 lbs Meat:" << endl;
                  cout << "4) Assortment of Spices/Herbs:" << endl;
                  cout << "5) Wool Gloves:" << endl;
                  cout << "6) Wool Coat:" << endl;
                  cout << "7) Light Leather Boots:" << endl;
                  cout << "8) Pack of 5 Torches:" << endl;
                  cout << "9) Pack of 5 Lanterns:" << endl;
                  cout << "10) 1 Quart of Oil:" << endl << endl; 
                  loop16:
                  cout << "Press 1 - 10 and Then Enter To Purachase An Item. Press 'b' To Go Back To The \nShop List. When done, press 'd'";
                  cin >> item_type;
                  switch (item_type) {
                         case '1':
                         case '2':
                         case '3':
                         case '4':
                         case '5':
                         case '6':
                         case '7':
                         case '8':
                         case '9':
                         case '10':
                         {
                              cout << "Enter amount: ";
                              cin >> amount;
                              inventory[item_type]+=amount;
                              cout << "Type " << item_type << " has " << inventory[item_type] << " items in it\n\n";
                              goto loop16;                        
                              }
                              break;
                         case 'b':
                              goto loop15;
                              break;
                         case 'd':
                              goto game;
                              break;
                         default:
                              {
                              cout << "Incorrect Command!";
                              goto loop16;
                              }         
                         }
                  
                  
             case '2':
                  cout << "\n\nWelcome To The Blacksmith!\n";
                  cout << "1) Hard Leather Gloves:" << endl; 
                  cout << "2) Hard Leather Boots:" << endl;
                  cout << "3) Hard Leather Torso:" << endl;
                  cout << "4) Chain Mail Helment:" << endl;
                  cout << "5) Chain Mail Torso:" << endl;
                  cout << "6) Chain Mail Pants:" << endl;
                  cout << "7) Plate Mail Helment:" << endl;
                  cout << "8) Plate Mail Torso:" << endl;
                  cout << "9) Plate Mail Pants:" << endl;
                  s = getch();
                    if (s=='b')
                    goto loop15;
                  break;
             case '3':
                  cout << "\n\nWelcome To The Potions and Magic Shop!\n"; 
                  cout << "1) Healing Potion:" << endl; 
                  cout << "2) Strength Potion:" << endl;
                  cout << "3) Poision:" << endl;
                  cout << "4) Dexterity Potion:" << endl;
                  cout << "5) Charisma Potion:" << endl;
                  cout << "6) Antidote Potion:" << endl;
                  cout << "7) Book of Fire:" << endl;
                  cout << "8) Book of Darkness:" << endl;
                  cout << "9) Book of Summons:" << endl;
                  cout << "10 Book of Healing:" << endl;
                  cout << "11) Mana Potion:" << endl;
                  cout << "12) Staff of Epicness:" << endl; 
                  s = getch();
                    if (s=='b')
                    goto loop15;
                  break;
             case '4':
                  cout << "\nweapons";
                  s = getch();
                    if (s=='b')
                    goto loop15;
                  break;
             case '5':
                  cout << "\nbar";
                  s = getch();
                    if (s=='b')
                    goto loop15;
                  break;
             case '6':
                  cout << "\njoe's house";
                  s = getch();
                    if (s=='b')
                    goto loop15;
                  break;
             default:
                  {
                  cout << "\n\nIncorrect Command!";
                  goto loop15;        
                  }
             }    
    
    game:
         cout << "GAME!";
    
    system("PAUSE");
    return EXIT_SUCCESS;
}

I realized the symbol thing was because I accidentally changed the inventory to char. But I still have the problem where item = 1 and 3 work fine, 2 outputs a huge number, and the rest just crash the computer. I tried setting all the values of int[] to 0 and that didn't work either. I'm on a different computer now ( the crash was unrelated to the code, it got a virus D: ) Any ideas?

- Timmah \m/
Topic archived. No new replies allowed.
Pages: 12