Accessing data with pointer to structure - Unix

This is a discussion on Accessing data with pointer to structure - Unix ; 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 ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Accessing data with pointer to structure

  1. Accessing data with pointer to structure

    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 so I
    don't understand what the problem is, obviously.

  2. Re: Accessing data with pointer to structure

    On Dec 8, 7:51 pm, 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 so I
    > don't understand what the problem is, obviously.


    The `menu' function is expecting a pointer to something of a different
    type than `struct request'. Look at its definition and figure out
    what it should be passed.

    I like your handle, by the way.

  3. Re: Accessing data with pointer to structure

    On Dec 8, 10:20 pm, fjbl...@yahoo.com wrote:
    > On Dec 8, 7:51 pm, 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 so I
    > > don't understand what the problem is, obviously.

    >
    > The `menu' function is expecting a pointer to something of a different
    > type than `struct request'. Look at its definition and figure out
    > what it should be passed.
    >
    > I like your handle, by the way.


    Ack! Yes. Stupid of me. I was looking at the "menu" string and not
    the menu function. Thanks.
    And glad you like the handle. nyuck nyuck.

+ Reply to Thread