Home  Interview Questions  Certifications  Aptitude Questions  Tutorials  Placement Papers  Search  Resume  Soft Skills  Video  Forum  Blog

Android app on Google Play

Technical Interview Questions

Java Interview Questions
Unix Interview Questions
SQL Interview Questions
C# Interview Questions

Aptitude Interview Questions
C/C++ Aptitude Questions
C Aptitude Questions

C Tutorial
C++ Tutorial

Programming Source Codes
C/C++ Source Codes
C# Source Codes

Online Quiz
C Online Quiz
C++ Online Quiz


Home > C Interview Questions >

How do you use a pointer to a function ?

 The hardest part about using a pointer-to-function is declaring it.
Consider an example. You want to create a pointer, pf, that points to the strcmp() function.

The strcmp() function is declared in this way:
int strcmp(const char *, const char * )

To set up pf to point to the strcmp() function, you want a declaration that looks just like the strcmp() function’s declaration, but that has *pf rather than strcmp:
int (*pf)( const char *, const char * );

After you’ve gotten the declaration of pf, you can #include and assign the address of strcmp() to pf: pf = strcmp; 

<< Go Back to C Interview Questions. 

Have a Question ? post your questions here. It will be answered as soon as possible.

Check Object Oriented Interview Questions for more Object Oriented Interview Questions with answers

Check Data Structure Interview Questions for more data structure interview questions with answers