#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Melbourne Australia
    Posts
    5
    Rep Power
    0

    Pointing to a Struct problem.


    I searched the forum for relevant material and found someone's example code but i don't know how to apply it - what i have done looks correct to me.

    here is the relevant code:

    typedef struct {Set *line;struct Catalog *head; struct Catalog *next;} Catalog;

    Catalog *threescat1; /*-publically available*/

    /*in a function that aims to 'free' a linked list of catalogs*/
    Catalog *catmember;

    catmember=threescat1->head;

    ^
    connect4.c(326) : Error: need explicit cast to convert
    from: struct Catalog*
    to : struct _N3connect4*


    Catmember and threescat1 are both of the same type: *catalog... Should i be using '.' instead of '->' ?.. im a little confused by the theory behind pointers pointing to pointers..
    Last edited by meowface; July 20th, 2003 at 12:40 AM.
  2. #2
  3. Left due to despotic ad-min
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Posts
    1,044
    Rep Power
    13
    Your problem isn't actually related to pointers at all; your typedef is actually incorrect.

    typedef struct ACatalog {Set *line;struct ACatalog *head; struct ACatalog *next;} Catalog;

    One of the "joys" (for want of a better word!) of typedefs is that a lot of compilers don't actually expand them until you try to use the typedef to declare a variable or (as in your case) when you use the variable. This results in errors being reported at a line in code that is not where the original error is.

IMN logo majestic logo threadwatch logo seochat tools logo