Well consider a few options.
First, C has no lambda expressions, although the latest C ++ is standard. It might be worth considering C ++ instead of C if this is a serious problem for you.
C can define and pass function pointers . Therefore, it is completely legal to pass a function as a parameter to another function.
You can also define functions for accepting a variable number of arguments , which may also be useful to you.
C macros can also be useful. You can, for example, do this:
#define f1( x ) g( (x), 1 ) #define f2( x ) g( (x), 2 ) int g( int x, int y ) { return ( x + y ) ; }
You can even do smart things with macros to allow macro overloading. This is not entirely ideal in terms of coding style, but it is possible.
Thus, there may be some tools to get what you want.
Update
The OP added an update to his post while I was about to, so if I understand that his goal is here, this is a rude suggestion.
It seems that the OP wants the selected function to have access to the index variable, which can be set in another place where it could try to use struct for parameters. Perhaps something like:
typedef struct mystring_s { char *s ; int i ; } mystring_t ; void f1( mystring_t *strp ) { } void g( void (*fn)( mystring_t * ), mystring_t *strp ) { (*fn)( strp ) ; } void set_i( mystring_t *strp, int v ) { strp->i = v ; } mystring_t s ; set_i( &s, 11 ) ; g( &f1, &s ) ; set_i( &s, 31 ) ; g( &f2, &s ) ;
Of course, he could also try to use a global value (which he apparently doesn't want or doesn't think is impossible), and he could even store a function pointer with data.
It's hard to know for sure if this is a workable idea for the OP, as it is really trying to do what C is not intended for. I think the problem is that he has a design idea in his head, and this is a bad choice for C. Perhaps it would be better to see how these requirements arose and change this overall design to something more C friendly than trying and make C to replace the capabilities of Haskell.