--- Hardy Huang <[EMAIL PROTECTED]> wrote:
>
> Hai,
> I'm trying to use pointer, array and struct
> together. I'm a newbie.
> Here is my code. I still don't know what's wrong
> with it. So guys plz help
> me out.
>
> #include <iostream>
> using namespace std;
> #include <conio.h>
>
> const int nameSize = 20;
> struct pizza
> {
> char name[nameSize];
> float diameter;
> float weight;
> };
>
> int main()
> {
> cout << "Welcome to William Wingate Pizza
> Analysis Service!\n";
> cout << "How many pizza do you want to
> make?\n";
>
> /////////////////
> int quantity;
> (cin >> quantity).get();
> pizza * guest=new pizza[quantity];
> /////////////////
>
>
>
///////////////////////////////////////////////////////////
> for (int i=1; i<=quantity; i++)
> {
> cout << "Enter number " << i << " pizza
> statistics!\n";
> cout << "Enter pizza name : ";
> cin.getline(guest[i]->name,nameSize);
> cout << "Enter pizza diameter : ";
> cin >> guest[i]->diameter;
> cout << "Enter pizza weight : ";
> (cin >> guest[i]->weight).get();
> }
>
>
///////////////////////////////////////////////////////////
> cout << "\nHere is your pizza statistics!\n";
>
>
///////////////////////////////////////////////////////////
> for (int i=1; i<=quantity; i++)
> {
> cout << "Pizza number " << i << endl;
> cout << "Name : " << guest[i]->name <<
> endl;
> cout << "Diameter : " << guest[i]->diameter
> << endl;
> cout << "Weight : " << guest[i]->weight
> << endl;
> }
>
>
///////////////////////////////////////////////////////////
> getch();
> return 0;
> }
>
> Thank you and Happy New Year
>
>
>
>
>
>
Hi Binit,
Firstly you didnt mention what problem are you facing
with the code.. (compiler error.. runtime error? )
The loop range you are using is from 1 to <quantity>.
It should be from 0 to <quantity -1>.
Regards
Manik
__________________________________
Do you Yahoo!?
Send holiday email and support a worthy cause. Do good.
http://celebrity.mail.yahoo.com
To unsubscribe : [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To reply to this message, go to:
http://groups.yahoo.com/group/Programmers-Town/post?act=reply&messageNum=4991
Please do not reply to this message via email. More information here:
http://help.yahoo.com/help/us/groups/messages/messages-23.html
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Programmers-Town/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/