Hi,
I have a struct in a .h file, and i want to use a function to define and initialize the struct and send a pointer back to main and use it.
How should i do it?
Does the struct needs global?
Many thanks!
Hi,
I have a struct in a .h file, and i want to use a function to define and initialize the struct and send a pointer back to main and use it.
How should i do it?
Does the struct needs global?
Many thanks!
If you want a global instance of the struct, declare it with extern in the header....and without extern in the implementation file.
Also.. declare your 'init' function in the .h file and define it in the .c file.
That is a common way of doing things....if it suits you.