Thread: struct/pointer compile error

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    1

    struct/pointer compile error

    Code:
    struct book {
        int pages;
        int year;
    } b1;
    
    b1.pages = 100;
    this gives me a compile error (at the "b1.pages = 100;" line):
    error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token


    any help appreciated, never seen this before..

    /n

  2. #2
    Registered User
    Join Date
    Oct 2007
    Posts
    36
    if u provide the assignment globally, the compiler will show the parse error...make the assignment in any of the functions, such as

    Code:
    int main() 
    {
         b1.pages  = 100;
    }
    this will solve the issue

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 07:17 PM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM