Thread: new to c progamming any one can help

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

    new to c progamming any one can help

    Hi all
    any one can help what are my mistakes, this program for a newspaper shop with monthely magazine. with out put something like
    201 Combat March 20 0 2.00 3.00
    201 magazine code, combat name of the title, month,number ordered,number sold,price wholesale and retail.
    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++)
    {
    printf ("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
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >#include< stdio.h>
    should be
    >#include <stdio.h>

    >struct News Record { int code ;
    you cannot have spaces in variable names. Suggest you use NewsRecord instead.

    >void list stock (sruct NewsRecord shop[20]; int c)
    Spaces again. Use liststock.
    Also, what is sruct? A typo I feel (struct).
    And why the semi-colon. Use a comma as a seperator.

    >char title[titlelength];
    the define is for Titlelength, not titlelength. Case sensativity applies.

    >float whole price;
    >float retail price;
    More spaces in names.

    ....... That's it, I can't be bothered to do any more, although I'm sure there's a lot. Run it through your compiler, fix the typos etc, then post again if you are still having trouble.

    And, use code tags when posting code.

    Code:
    My compilers output:
    
    Error E2209 D:\C\junk\junk1.c 1: Unable to open include file ' stdio.h'
    Error E2141 D:\C\junk\junk1.c 4: Declaration syntax error
    Error E2449 D:\C\junk\junk1.c 13: Size of 'list' is unknown or zero
    Error E2141 D:\C\junk\junk1.c 13: Declaration syntax error
    Error E2141 D:\C\junk\junk1.c 13: Declaration syntax error
    Error E2040 D:\C\junk\junk1.c 15: Declaration terminated incorrectly
    Error E2141 D:\C\junk\junk1.c 15: Declaration syntax error
    Error E2141 D:\C\junk\junk1.c 15: Declaration syntax error
    Error E2380 D:\C\junk\junk1.c 22: Unterminated string or character constant
    Error E2190 D:\C\junk\junk1.c 27: Unexpected }
    Error E2450 D:\C\junk\junk1.c 28: Undefined structure 'magazine'
    Error E2303 D:\C\junk\junk1.c 28: Type name expected
    Error E2380 D:\C\junk\junk1.c 68: Unterminated string or character constant
    Error E2190 D:\C\junk\junk1.c 80: Unexpected }
    Error E2450 D:\C\junk\junk1.c 86: Undefined structure 'newsrecord' in function main
    Error E2450 D:\C\junk\junk1.c 86: Undefined structure 'newsrecord' in function main
    Error E2449 D:\C\junk\junk1.c 86: Size of 'shop' is unknown or zero in function main
    Error E2450 D:\C\junk\junk1.c 86: Undefined structure 'newsrecord' in function main
    Error E2450 D:\C\junk\junk1.c 86: Undefined structure 'newsrecord' in function main
    Error E2449 D:\C\junk\junk1.c 86: Size of 'shop' is unknown or zero in function main
    Error E2451 D:\C\junk\junk1.c 87: Undefined symbol 'o' in function main
    Error E2141 D:\C\junk\junk1.c 87: Declaration syntax error in function main
    Error E2380 D:\C\junk\junk1.c 92: Unterminated string or character constant in function main
    Error E2121 D:\C\junk\junk1.c 93: Function call missing ) in function main
    Error E2451 D:\C\junk\junk1.c 97: Undefined symbol 'order' in function main
    Error E2228 D:\C\junk\junk1.c 97: Too many error or warning messages in function main
    *** 26 errors in Compile ***
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed