Hi ..
I have to use a global struct object, but I want to call some init function just when the object is created. In C++ this is achieved without hassle by writing a constructor.
How do I achieve this in C? In C++ the init function is called before main() which is quite a pun for me in C.
ex: main.c
mystruct ms;
int main()
{
... some ops on ms ..
}
I have to use a global struct object, but I want to call some init function just when the object is created. In C++ this is achieved without hassle by writing a constructor.
How do I achieve this in C? In C++ the init function is called before main() which is quite a pun for me in C.
ex: main.c
mystruct ms;
int main()
{
... some ops on ms ..
}
Comment