Nested Structures

This is a discussion on Nested Structures within the C Programming forums, part of the General Programming Boards category; I've tried a couple different ways to do this without success. Just trying to see if I overlooked anything? The ...

  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,796
    >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, 12:22 PM
  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, 09:35 PM
  5. Nested structures
    By Garfield in forum C Programming
    Replies: 8
    Last Post: 10-08-2001, 01:11 PM

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