passing argument from incompatible pointer type

This is a discussion on passing argument from incompatible pointer type within the C Programming forums, part of the General Programming Boards category; Hi guys, I'm getting the warning: passing argument 2 of 'plan_route' from incompatible pointer type whenever I try to compile ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    4

    passing argument from incompatible pointer type

    Hi guys, I'm getting the warning:

    passing argument 2 of 'plan_route' from incompatible pointer type

    whenever I try to compile my code and I'm not sure what I'm doing wrong.

    Code:
    int main(void){
            struct city *cities=get_cities();
            struct request *req=get_requests();
            plan_route(cities, req);
    
            return 0;
    }
    Code:
    struct request{
        struct request *next;
        char depart[20];
        char dest[20];
        float f;
    };
    Code:
    struct request *get_requests(){
            struct request *head=malloc(sizeof(struct request));
            struct request *temp=head;
            while (!feof(stdin)){
                    scanf("%s %s %f", temp->depart, temp->dest, &temp->f);
                    temp->next=malloc(sizeof(struct request));
                    temp=temp->next;
            }
            return head;
    }
    
    
    struct city *plan_route(struct city *head, struct request *req){
    
             ...
    }
    I'm hoping the rest of my code isn't necessary. Does anyone see the error I may have made?

    Thanks in advance.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    Do you have a header file or prototype for these functions? If so, make sure all have the exact same signature.

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    4
    Yup, small error in the header file. Thanks a lot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LDAP Query
    By Travoiz in forum C++ Programming
    Replies: 0
    Last Post: 08-13-2009, 03:58 PM
  2. Replies: 0
    Last Post: 03-20-2008, 08:59 AM
  3. Initialization from incompatible pointer type
    By Jailan in forum C Programming
    Replies: 9
    Last Post: 10-28-2007, 10:17 PM
  4. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-30-2005, 12:21 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 11:03 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21