When you declare a function in a program with structs, does it matter where the argument is placed or it does not matter?
Here is an example:
Code:typedef struct
{
}
typedef struct
{
}
int newIncident();
Printable View
When you declare a function in a program with structs, does it matter where the argument is placed or it does not matter?
Here is an example:
Code:typedef struct
{
}
typedef struct
{
}
int newIncident();
If you typedef your structs, the typedef has to come before any
prototypes which reference that typedef. However in this case,
the prototype newIncident() doesn't reference any structs,
so it can appear anywhere.
However it conventional to lay out a header by declaring the
structs and other types first, then declaring the functions.
If the function needs a struct that references for example the two previous structs what should I do? You have just played with my curiosity. Here is an example of what I mean:
Code:
typedef struct
{
}a;
typedef struct
{
}b;
typedef struct
{
a reported;
b coordinates;
}
int newIncident();