problem with structure !!!!

This is a discussion on problem with structure !!!! within the C Programming forums, part of the General Programming Boards category; Hello all I've wrote this header file Code: struct sign { char sign; }signlib; struct identifier { char *variable; double ...

  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    1

    problem with structure !!!!

    Hello all
    I've wrote this header file
    Code:
    struct sign
    {
        char sign;
    }signlib;
    
    struct identifier
    {
        char *variable;
        double number;
        struct identifier *id;
    }identify;
    
    
    struct lib 
    {
        char hash;
        char *include;
        signlib sign1;
        identify lib_name;
        char dot ;
        char h;
        signlib sign2;
    };
    and when I compiled it i have this error message :
    PHP Code:
    tree.h:18 errorexpected specifier-qualifier-list before signlib 
    can any one tell me what is the problem ???
    thanks.

  2. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    17
    The compiler does not have enough information, that is the problem.

    You should try something like these:

    Code:
    typedef struct signlib
    {
        char sign;
    }signlib;

  3. #3
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,786
    adrian2009's suggestion looks correct. The problem is that in the original example, signlib is a variable of type struct sign.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. problem getting structure to work in my function
    By Tom Bombadil in forum C Programming
    Replies: 18
    Last Post: 05-28-2009, 09:53 AM
  2. Problem with structure and class
    By Bargi in forum C++ Programming
    Replies: 3
    Last Post: 09-25-2007, 02:30 AM
  3. Problem with arrays inside a structure
    By babu in forum C Programming
    Replies: 4
    Last Post: 07-12-2007, 09:35 AM
  4. accessing structure pointer problem
    By godhand in forum C Programming
    Replies: 2
    Last Post: 04-09-2004, 10:52 PM
  5. Problem checking for numeric value in a structure
    By ronkane in forum C++ Programming
    Replies: 4
    Last Post: 01-20-2002, 01:53 PM

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