Trouble accessing data with pointer to structure

Discussion in 'C Programming' started by drhowarddrfine, Dec 9, 2007.

  1. I'm playing around with data passed in a structure. In one function I
    do this:

    /* path is defined as char* path[10] in the struct */
    struct request customer_request;
    if(strcmp("order",customer_request->path[0])==0)
    order(customer_request);

    In the called 'order' routine, I do this:

    void order(struct request *customer_request){
    if(strcmp("menu",customer_request->path[1])==0)
    menu(customer_request);

    but I get a compiler error:
    warning: passing arg 1 of `menu' from incompatible pointer type
    drhowarddrfine, Dec 9, 2007
    #1
    1. Advertising

  2. drhowarddrfine

    James Kuyper Guest

    drhowarddrfine wrote:
    > I'm playing around with data passed in a structure. In one function I
    > do this:
    >
    > /* path is defined as char* path[10] in the struct */
    > struct request customer_request;
    > if(strcmp("order",customer_request->path[0])==0)
    > order(customer_request);
    >
    > In the called 'order' routine, I do this:
    >
    > void order(struct request *customer_request){
    > if(strcmp("menu",customer_request->path[1])==0)
    > menu(customer_request);
    >
    > but I get a compiler error:
    > warning: passing arg 1 of `menu' from incompatible pointer type


    Well, what is the declared type of the first parameter of menu()? If it
    is indeed incompatible with 'struct request*', that would explain the
    error message you're getting.
    James Kuyper, Dec 9, 2007
    #2
    1. Advertising

  3. On Dec 8, 10:18 pm, James Kuyper <> wrote:
    > drhowarddrfine wrote:
    > > I'm playing around with data passed in a structure. In one function I
    > > do this:

    >
    > > /* path is defined as char* path[10] in the struct */
    > > struct request customer_request;
    > > if(strcmp("order",customer_request->path[0])==0)
    > > order(customer_request);

    >
    > > In the called 'order' routine, I do this:

    >
    > > void order(struct request *customer_request){
    > > if(strcmp("menu",customer_request->path[1])==0)
    > > menu(customer_request);

    >
    > > but I get a compiler error:
    > > warning: passing arg 1 of `menu' from incompatible pointer type

    >
    > Well, what is the declared type of the first parameter of menu()? If it
    > is indeed incompatible with 'struct request*', that would explain the
    > error message you're getting.


    Ack! Yes. Stupid of me. I was looking at the "menu" string and not
    the menu function. Thanks.
    drhowarddrfine, Dec 9, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    16
    Views:
    728
    Stephen Sprunk
    Jul 24, 2006
  2. Replies:
    6
    Views:
    371
    Jack Klein
    Aug 27, 2006
  3. sakitah
    Replies:
    9
    Views:
    330
    Krishanu Debnath
    Nov 11, 2005
  4. Ram
    Replies:
    3
    Views:
    427
    Barry Schwarz
    Mar 24, 2009
  5. A
    Replies:
    27
    Views:
    1,593
    Jorgen Grahn
    Apr 17, 2011
Loading...

Share This Page