Structures

C

Chris Dollin

dmp said:
How to create a structure inside structure?

The usual way is to write code. What did you try and how didn't it
work?

[I'd do something like
struct outer { int spoo; struct inner { long tube; }; };

struct outer limits;
]
 
C

c.lang.myself

dmp said:
How to create a structure inside structure?

The usual way is to write code. What did you try and how didn't it
work?

[I'd do something like
  struct outer { int spoo; struct inner { long tube; }; };
I think this nesting declaration of structure is not allowed in c.
compiling this declaration would generate an error.
Correct use would be as
struct inner
{
long tube;
}str1;
struct outer
{
int spoo;
str1 inn; //inner structure's object
};
 
M

maverik

Chris forgot the tag for the inner structure; it should be

  struct outer { int spoo; struct inner { long tube; }; foo };

It's a syntax error. It should be:

struct outer { int spoo; struct inner { long tube; } foo; };
 
R

Richard Tobin

struct outer { int spoo; struct inner { long tube; }; };
[/QUOTE]
I think this nesting declaration of structure is not allowed in c.
compiling this declaration would generate an error.

Chris forgot the tag for the inner structure; it should be

struct outer { int spoo; struct inner { long tube; }; foo };

Apart from that, it's legal.
Correct use would be as
struct inner
{
long tube;
}str1;
struct outer
{
int spoo;
str1 inn; //inner structure's object
};

This is also wrong! You should have

struct inner inn; // inner structure's object

or perhaps you meant to use typedef.

-- Richard
 
J

Joachim Schmitz

Richard said:
Chris forgot the tag for the inner structure; it should be

Isn't 'inner' the tag? Chris forgot the variable name.
struct outer { int spoo; struct inner { long tube; }; foo };

And you got it wrong :cool: too.

Bye, Jojo
 
R

Richard Tobin

Chris forgot the tag for the inner structure; it should be

Isn't 'inner' the tag? Chris forgot the variable name.[/QUOTE]

The member name, actually.
And you got it wrong :cool: too.

Yes :) Let's hope we have exhausted the possible mistakes here...

-- Richard
 
C

Chris Dollin

Richard said:
Isn't 'inner' the tag? Chris forgot the variable name.

The member name, actually.[/QUOTE]

Argh! So I did.
Yes :) Let's hope we have exhausted the possible mistakes here...

There are more mistakes in heaven and earth, Horatio, than are
dreamt of in your philosophy. I think some of them live in my beard.
 
J

Joachim Schmitz

Richard said:
Isn't 'inner' the tag? Chris forgot the variable name.

The member name, actually.[/QUOTE]

Rats! 'variable name' felt wrong somehow, but I couldn't remember the
correct term :cool:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top