new to c++ any one can help

This is a discussion on new to c++ any one can help within the C++ Programming forums, part of the General Programming Boards category; Hi all any one can help what are my mistakes, this program for a newspaper shop with monthely magazine. thanks. ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    2

    new to c++ any one can help

    Hi all
    any one can help what are my mistakes, this program for a newspaper shop with monthely magazine.
    thanks.
    # include < stdio.h>
    #define Titlelength 20

    struct News Record { int code ;
    char title[titlelength];
    char month[10];
    int numordered;
    int numsold;
    float whole price;
    float retail price;
    };

    void list stock (sruct NewsRecord shop[20]; int c)
    int k;
    for (k= 0; k<c; k++)
    {
    pritf ("magazine code number % d",k);
    printf ("name %s", magazinename[magazine]);
    printf ("name %s", shop[k].name);
    printf ("name %s" ,monthname[month]);
    printf ("wholeprice %F",shop[k].sterlingprice;
    printf ("retailprice %F,shop[k].sterlingprice);
    printf ( "numsold %d" ,k);
    printf ("stock level%d \n",shop[k].stocklevel);
    };

    }
    int sellmagazin(struct magazine shop[20],intc)
    {
    int many, order. Want;
    liststock (shop, c);
    do
    {
    printf ("what do you want!");
    scanf (" %d" ,& want) ;
    }
    while (want >c);
    printf ("how many do want!");
    scanf ("%d" ,& many);
    printf (" please pay %f", shop [want].sterling price);

    if (many ,shop[want].stocklevel)
    order=1000;
    else
    order=want;
    shop(want).stocklevel-=many;
    return order;
    }
    void order newsrecord (struct newspaper shop [20],int want)

    {
    int many;
    printf("how many %s do you need",shop[want].name);
    shop[want].stoklevel+=many;
    }

    if (c<20)

    {
    printf("Enter magazine code number:");
    scanf("%d",&code num);
    printf("Enter the magazine title:");
    scanf("%s", &magazine[20]. title);
    printf("Enter the month name:");
    scanf("%s", &month[10]. name);
    printf("Enter the number to be order:");
    scanf("%d",&shop[c].stocklevel);
    printf("Enter the number to be sold;
    scanf("%d",&shop[c].stocklevel);
    printf("Enter whole price of magazine :");
    scanf("%f",&shop[k].sterlingprice);
    printf("Enter retail price of magazine:");
    scanf("%f",&shop[k].steringprice);

    return 1;
    }

    else
    return 0;
    }

    void main()

    {

    struct newsrecord shop[20];
    int c=o ;char letter;float profit,sum profit;

    do

    {
    printf("Do you want to O)rder or S)ell L)ist C)alculate profit for each title T)otal;
    scanf("%c",&letter);
    if ((letter=='O')||(letter=='o'))

    {
    if(!order magazine title (shop,c++)
    printf("you can't order any more\n");
    }
    else if ((letter=='S')||(letter=='s'))
    {
    order number=sell magazine(shop,c);
    if (order number !=1000)

    order magazine(shop,order number);
    }
    else if ((letter= ='L')||(Letter= ='l')
    List stock (shop,c);
    }
    else if ((letter= ='C')||(letter= ='c'))
    {
    profit for each title=number sold *(retail price - whole sell price)
    printf("profit for each titl=%f") scanf("%f",&shop[c].sterling price);
    }
    else if ((letter= ='T')||(letter= ='t')
    for(I=0=sum;I<num -of-title;I++)
    sum=sum+profit for each title
    printf("sum of profit for each title per day=%f");
    scanf("%f",&sum);

    };
    }
    }

  2. #2
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    359
    Can anyone indent there code these days?

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    85
    first, when you do the #includes, you cannot leave spaces. try #include<stdio.h>

    i'm not really sure what else is wrong, why don't you post your errors? it may you made an error with your open and close brackets in the if- else statements.

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    i noticed alot, but i wont even try to post them, try to repost your code, with the code tags, then i will help you
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  5. #5
    Registered User
    Join Date
    May 2002
    Posts
    27
    You misspelled printf(you put pritf) here:

    void list stock (sruct NewsRecord shop[20]; int c)
    int k;
    for (k= 0; k<c; k++)
    {
    pritf ("magazine code number % d",k);
    printf ("name %s", magazinename[magazine]);
    printf ("name %s", shop[k].name);

  6. #6
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225

    Errors?

    They're quite easy to figure out You should try your best and figure it out. It's the best way to practice

  7. #7
    i dont know Vicious's Avatar
    Join Date
    May 2002
    Posts
    1,200

    yah

    errors are easy to fix unless you have 4600 lines like in my game i just made. Now thats hard to fix errors or flaws in the game.
    What is C++?

  8. #8
    Registered User billholm's Avatar
    Join Date
    Apr 2002
    Posts
    225

    Talking

    Yah!

    It may take you two years but at least you can still solve it hehehe!

    It took me two months to debug my database program.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21