c++ code crashing dont know why

hi guys.. i've got the c++ code only problem is the .exe thing keeps crashing any one with any idea what i could do?

thats the code..

#include <iostream>

#include <string>




using namespace std;




struct Drink {

string sDrinkName;

float DrinkCost;

float Qty;

};




int main()

{
//Create 5 drinks: index starts at 0 so we substract 1.

Drink theDrink[4];

//Define the drinks.

theDrink[0].sDrinkName = "Coca Cola ";

theDrink[0].DrinkCost = 1.50;

theDrink[0].Qty = 30;

theDrink[1].sDrinkName = "Sprite ";

theDrink[1].DrinkCost = 1.60;

theDrink[1].Qty = 30;

theDrink[2].sDrinkName = "Fanta";

theDrink[2].DrinkCost = 1.70;

theDrink[2].Qty = 30;

theDrink[3].sDrinkName = "Ginger Beer";

theDrink[3].DrinkCost = 1.90;

theDrink[3].Qty = 30;

theDrink[4].sDrinkName = "Powerade";

theDrink[4].DrinkCost = 3.50;

theDrink[4].Qty = 20;



for ( int i=0; i<5; i++)

cout << " " << theDrink[i].sDrinkName << " " << theDrink[i].DrinkCost << " " << theDrink[i].Qty <<endl;





cout << "Enter the name of the Drink you want: ";

char drink_name;

cin >> drink_name;

while(1)

{

//Does the client want to quit?

char Option = 0;

if(Option == 'q')

{

break;

}

//The client doesn't want to quit so we move on below.

//Implement picking a drink and pay for it.

}



system("pause");
return 0;

}
Drink theDrink[4];
Has only four elements (index 0,1,2 and 3), not five.
Next time please put your code between [code] and [/code] tags.
Hey man sorry I don't really get what you saying this is my 1st time on c++ also sorry for putting up a horrible long post..
And code tag it. Read the first sticky in the beginner forums. And the article on code tags in the article forums.
tummychow wrote:
And code tag it.

I've already told him, please read the other posts before posting.
Whoops. Sorry.
Topic archived. No new replies allowed.