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();
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.
I'm the author of MiniBasic: How to write a script interpreter and Basic Algorithms
Visit my website for lots of associated C programming resources.
https://github.com/MalcolmMcLean
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();