So my init_console() function prototype will be pretty long (once I include all of the functions). Is there a better, or more concise way of doing this?
Essentially this is similar to the way virtual functions work in C++. Each C++ class that has virtual functions contains a pointer to a compiler-provided data structure (the VTable), which has a list of pointers to the virtual functions of that class. Conceptually it's similar to this (pseudo) C/C++ code:
int YourClass_func1(int);
void YourClass_func2(char*, float);
struct YourClass_VTable
{
int (*func1)(int) = &YourClass_func1;
void (*func2)(char*, float) = &YourClass_func2;
} YourClass_VTable;
struct YourClass
{
YourClass_VTable* vtable_ptr = &YourClass_VTable;
// other variables...
};
// Inside another function
YourClass foo;
// Calling a virtual function
foo->vtable_ptr->func1(42);
In your situation, you can optimise somewhat by removing the VTable and providing the pointers to the functions in the struct (class) directly, but the principle is the same.
Or you could do something that looks a lot like the structure way; you could do it like Glut and other libraries do; before calling the init_console function (the function that would have a lot of parameters), you could create several functions like this:
Though if you have a lot of these functions, you'd get loads of these functions (mutators in a certain way). And to read them you'd have to make accessors. You could just make the variables public or use the, as said before, structure way (which is more elegant in my opinion).
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
#include <stdio.h>
#include <stdlib.h>
typedef void (* FPTR)();
void exper()
{
puts("MU ha ha ha ha ");
}
int main()
{
FPTR r = exper;
puts("Bwi ha ha ha ha ");
(*r)();
return EXIT_SUCCESS;
}