Trouble accessing data with pointer to structure

D

drhowarddrfine

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
 
J

James Kuyper

drhowarddrfine said:
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.
 
D

drhowarddrfine

drhowarddrfine said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top