program suddenly stops working
Jun 17, 2013 at 6:49pm UTC
hello. i wrote this inventory practice code and everytime i compile+run it, it says "inventory practice.exe has stopped working" and then closes, i cant figure out what i did wrong
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#include <iostream>
#include <string>
using namespace std;
int main ()
{
const int max_items = 5;
string pack[max_items];
int numItems;
pack[numItems++] = "sword" ;
pack[numItems++] = "shield" ;
pack[numItems++] = "boots" ;
pack[numItems++] = "helmet" ;
pack[numItems++] = "gloves" ;
cout << "your pack has:\n" ;
for (int i = 0; i < numItems; ++i)
{
cout << pack[i] << endl;
}
system ("PAUSE" );
}
Jun 17, 2013 at 6:52pm UTC
What is the initial value of numItems
?
Topic archived. No new replies allowed.