Is it possible to define a function as a parameter with it's own pa...

Is it possible to define a function with it's own parameters as an argument of a function? Pay attention to the followingg example:


void test(char param1, void (*access)())

{

//whatever

}


void func(void)

{

cprintf("
This is a test");

}


void main(void)

{

test(10, func);

}




I wanna to give some parameters to my "func" function

like this:


test(10, func(1, 2));


But it seems that I can't do that!

Is there any practical way to do so? If so, please don't hesitate to share your information with me.


Cheers,

Mehdi


URL:http://www.tabesh.com

Comments

  • saying something like test(10, func(1, 2)); implies a function call to func first, So the above means that you want the function func to be evaluated first and the return value from it to be passed as a parameter to test. only a pointer to a function can be passed. I suppose you will have to pass the parameters to func as extra parameters to test() so that test can call the function func with those parameters.


    Regards

    Vijay

    : Is it possible to define a function with it's own parameters as an argument of a function? Pay attention to the followingg example:


    : void test(char param1, void (*access)())

    : {

    : //whatever

    : }


    : void func(void)

    : {

    : cprintf("
    This is a test");

    : }


    : void main(void)

    : {

    : test(10, func);

    : }


    :

    : I wanna to give some parameters to my "func" function

    : like this:


    : test(10, func(1, 2));


    : But it seems that I can't do that!

    : Is there any practical way to do so? If so, please don't hesitate to share your information with me.


    : Cheers,

    : Mehdi







Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories