>Why the structures must be declared outside?
>is it a must to declare structure outside main?
The structure must be defined before it can be used. A structure definition, like any other variable, has a scope, and in your example, the code requires that the struct is defined outside main to allow grade() to take it as a parameter.

Quite often you'll find that struct definitions go at the top of the source file, or in the header file.

Originally posted by The Dog I disagree here. I think that your(Hammer) initial reply was right.
A structure declaration is when an instance of that structure is declared.

The structure definition is when the structure is initially defined, ie. where it is stated what the members of that type(struct) would be.

To me it sounds logical.

It might sound logical, and that alone is the reason for my wording in my first post. But then I consulted the gold old K&R2 bible, and found the correct definition was as per the quote in my last post. If you have the book, section 6.1 refers to this.

Here's a couple of other qoutes to assist:

Code:

struct point {
int x;
int y;
};

The keyword struct introduces a structure declaration, which is a list of declarations enclosed in braces.
<snip>
A structure declaration that is not followed by a list of variables reserves no storage; it merely describes a template or shape of a structure. If the declaration is tagged, however, the tag can be used later in definitions of instances of the structure. For example, given the declaration of point above:

>u people are screwing up simple things!!!!!!!!
C is very simple, using C is far from simple.

>A structure declaration is when an instance of that structure is declared.
>The structure definition is when the structure is initially defined,
>ie. where it is stated what the members of that type(struct) would be.
You have it backward. The structure definition is when the instance is declared and memory is set aside. The declaration is when the specifics of the structure in general are created so that the compiler can create an instance of it.