Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Trouble accessing data with pointer to structure

Reply
Thread Tools

Trouble accessing data with pointer to structure

 
 
drhowarddrfine
Guest
Posts: n/a
 
      12-09-2007
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
 
Reply With Quote
 
 
 
 
James Kuyper
Guest
Posts: n/a
 
      12-09-2007
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.
 
Reply With Quote
 
 
 
 
drhowarddrfine
Guest
Posts: n/a
 
      12-09-2007
On Dec 8, 10:18 pm, James Kuyper <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simple structure and copying data to pointer of the same structure A C++ 27 04-16-2011 11:07 PM
Accessing complex data from a linked list based data structure.. Ram C Programming 3 03-24-2009 02:15 AM
pointer to structure from pointer to member sieg1974@yahoo.com C Programming 6 08-27-2006 01:20 AM
Accessing structure elements using pointer math - padding worries? quantumred@gmail.com C Programming 16 07-24-2006 10:51 PM
Accessing a Structure Using a Pointer sakitah C++ 9 11-11-2005 07:11 AM



Advertisments