I was just wondering if a variable declared and defined inside a structure can be initialized to a certain value, was planning on using function pointers to mimic the classes in OOP.
Example COde:
typedef struct{
int x;
int (*manipulateX)(int) = &manipulateX;
}x = {0};
void main()
{
getch();
}
int manipulateX(int x)
{
x = x + 1;
return x;
}
Starting with C99, you can use designated initializers to set fields of structures to values, as follows: