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!
This is a discussion on Help in structures and functions within the C Programming forums, part of the General Programming Boards category; Hi, I have a struct in a .h file, and i want to use a function to define and initialize ...
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.
Manasij Mukherjee | gcc-4.8.0 @Arch Linux
Slow and Steady wins the race... if and only if :
1.None of the other participants are fast and steady.
2.The fast and unsteady suddenly falls asleep while running !