Thread: incompatible pointer type

  1. #1
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252

    incompatible pointer type

    Hey guys im getting an assignment from incompatible pointer type
    any idea's why

    drinkCat = menu->headCategory; this is the line of code where the error is

    Code:
    void displaySummary(GJCType* menu, char drinkType, int inputInt)
    {
    
        
        CategoryTypePtr *drinkCat;
        
        if(inputInt == 1)
        {
           printf("Hot Drinks Summary\n");
           printf("---------------------\n");
           
           assert(menu != NULL);
        
           drinkCat = menu->headCategory;
        
           while(drinkCat !=NULL)
           {
               
           
              /* keep printing the next list of hot drinks*/
              drinkCat= drinkCat->nextCategory;
           }
           
        
        }
        
     
       
    
    
    
    }
    
    
    typedef struct category* CategoryTypePtr;
    typedef struct item* ItemTypePtr;
    
    /* Structure definitions. */
    typedef struct price
    {
       unsigned dollars;
       unsigned cents;
    } PriceType;
    
    typedef struct item
    {
       char itemID[ID_LEN + 1];
       char itemName[MAX_NAME_LEN + 1];
       PriceType prices[NUM_PRICES];
       char itemDescription[MAX_DESC_LEN];
       ItemTypePtr nextItem;
    } ItemType;
    
    typedef struct category
    {
       char categoryID[ID_LEN + 1];
       char categoryName[MAX_NAME_LEN + 1];
       char drinkType;      /* (H)ot or (C)old. */
       char categoryDescription[MAX_DESC_LEN];
       CategoryTypePtr nextCategory;
       ItemTypePtr headItem;
       unsigned numItems;
    } drinkType;
    
    typedef struct gjc
    {
       CategoryTypePtr headCategory;
       unsigned numCategories;
    } GJCType;

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    Code:
    CategoryTypePtr *drinkCat;
    This is a pointer to a pointer.
    Code:
    typedef struct category* CategoryTypePtr;
    
    //...
    CategoryTypePtr nextCategory;
    //...
    This is a pointer.

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Now you know why typedefing pointers is a bad thing. And knowing is half the battle!


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252

    problem

    I cant change the struct though at all so how can i get rid of that error?

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    903
    I thought my explanation was clear... Remove the '*' in the first code I posted...

  6. #6
    Musicman - Canora
    Join Date
    Aug 2005
    Location
    Melbourne
    Posts
    252
    thanks buddy

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. warning: assignment from a incompatible pointer type
    By enderandrew in forum C Programming
    Replies: 8
    Last Post: 09-22-2007, 04:07 AM
  2. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM