struct/pointer compile error

This is a discussion on struct/pointer compile error within the C Programming forums, part of the General Programming Boards category; Code: struct book { int pages; int year; } b1; b1.pages = 100; this gives me a compile error (at ...

  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, 02:17 AM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 10: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, 09:11 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-30-2005, 12:21 AM

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