Thread: Nested Structures

  1. #1
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681

    Nested Structures

    I've tried a couple different ways to do this without success. Just trying to see if I overlooked anything?

    The way I've been doing nested structures is like this:
    Code:
    struct a
      {
      /* blah blah blah */
      };
    struct b
      {
      /* whatever */
      };
    struct c
      {
       struct a z;
       struct b y;
      };
    And then assign a variable for struct c in the main program. Is there a way to do it all at once? Such as:
    Code:
    struct c
      {
      struct a
        {
        /* blah blah blah */
        };
       struct b
        {
         /* whatever */
         };
       };
    I tried to do it like above and the compiler doesn't complain until I try to access the variables inside of a. Any tips/suggestions?

  2. #2
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Nevermind, figured it out. I love how asking a question (by typing or speaking it) and jar loose some information.

    If anyone is interested:
    Code:
    struct
      {
      struct
        {
         /* blah blah blah */
         }a;
        struct
        {
         /* whatever */
        }b;
      }c;

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I love how asking a question (by typing or speaking it) and jar loose some information.
    A teddy bear sits on top of my monitor (at work and at home) to provide such services when I need them.
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Nested Structures Possible?
    By thetinman in forum C++ Programming
    Replies: 6
    Last Post: 09-05-2007, 11:22 AM
  2. Nested Structures - User Input
    By shazg2000 in forum C Programming
    Replies: 2
    Last Post: 01-09-2005, 10:53 AM
  3. Nested structures
    By Supar in forum C++ Programming
    Replies: 2
    Last Post: 04-03-2003, 09:27 PM
  4. Nested Structures
    By Inept Pig in forum C Programming
    Replies: 4
    Last Post: 06-14-2002, 08:35 PM
  5. Nested structures
    By Garfield in forum C Programming
    Replies: 8
    Last Post: 10-08-2001, 12:11 PM