Thread: initalizer for scalar variable requires one element??

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    162

    initalizer for scalar variable requires one element??

    Dev-C++ gives me that error when I try to compile this code:

    MENU *menuitem[] = {
    {100, 100, "MAIN MENU", 0},
    {100, 125, "New Game", 1},
    {100, 140, "Load Game", 0}
    };

    MENU is a structure. What does this error mean and what do I do to fix it. Thanks alot!

  2. #2
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    You might try changing the name of your structure to something besides MENU. I think this is a predefined type in windows (WINAPI) programming.

  3. #3
    ....
    Join Date
    Aug 2001
    Location
    Groningen (NL)
    Posts
    2,380
    Try this:

    MENU menuitem [] = {
    {100, 100, "MAIN MENU", 0},
    {100, 125, "New Game", 1},
    {100, 140, "Load Game", 0}
    };

    You want an array of structures and not an array of pointers to those structures. A scalar is a single variable (for example: int a, just like a pointer is, that's why you compiler complained about it. You can't assign a structure to a single variable.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What error in this code?Help me!
    By KySiRo in forum C++ Programming
    Replies: 8
    Last Post: 12-20-2006, 03:45 PM
  2. Sorting a 2-dimensional array
    By kmoyle73 in forum C++ Programming
    Replies: 3
    Last Post: 05-05-2004, 01:54 PM
  3. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM
  4. sorting
    By penny_731729 in forum C Programming
    Replies: 3
    Last Post: 04-28-2003, 10:56 AM
  5. Binary searches
    By Prezo in forum C Programming
    Replies: 4
    Last Post: 09-10-2002, 09:54 PM