Jump to content

help with passing a pointer to a function to another function

- - - - -

  • Please log in to reply
1 reply to this topic

#1
csepraveenkumar

csepraveenkumar

    Learning Programmer

  • Members
  • PipPipPip
  • 52 posts
how is the pointer to a particular function passed in the following code
qsort((void **)lineptr,0,nlines-1,[B][I](int(*)(void*,void*))(numeric?numcmp:strcmp)[/I][/B]);
is it the normal way to pass a pointer to a function to another function i.e. by writing the name of the function after what seems to be the declaration of the function?

#2
L0s3r™

L0s3r™

    Newbie

  • Members
  • Pip
  • 9 posts

csepraveenkumar said:

how is the pointer to a particular function passed in the following code

qsort((void **)lineptr,0,nlines-1,[B][I](int(*)(void*,void*))(numeric?numcmp:strcmp)[/I][/B]);
is it the normal way to pass a pointer to a function to another function i.e. by writing the name of the function after what seems to be the declaration of the function?

Seriously I don't get what you are trying to do here.But...

Definition of qsort:

void qsort( void** , int , int , int(*funptr)(void* , void*) );

Calling it:

qsort( , , , func1); //if func is the function you wanna call ; remember it should match with the prototype of your declaration of function pointer in definition




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users