Function Pointer in C - Tutorialspoint

文章推薦指數: 80 %
投票人數:10人

Function Pointers point to code like normal pointers. In Functions Pointers, function's name can be used to get function's address. Home CodingGround Jobs Whiteboard Tools Business Teachwithus TrendingCategories DataStructure Networking RDBMS OperatingSystem Java iOS HTML CSS Android Python CProgramming C++ C# MongoDB MySQL Javascript PHP SelectedReading UPSCIASExamsNotes Developer'sBestPractices QuestionsandAnswers EffectiveResumeWriting HRInterviewQuestions ComputerGlossary WhoisWho FunctionPointerinC CServerSideProgrammingProgramming FunctionPointerspointtocodelikenormalpointers.InFunctionsPointers,function’snamecanbeusedtogetfunction’saddress.Afunctioncanalsobepassedasanargumentsandcanbereturnedfromafunction.Declarationfunction_return_type(*Pointer_name)(functionargumentlist)Example LiveDemo#include intsubtraction(inta,intb){   returna-b; } intmain(){   int(*fp)(int,int)=subtraction;   //Callingfunctionusingfunctionpointer   intresult=fp(5,4); printf("Usingfunctionpointerwegettheresult:%d",result); return0; }OutputUsingfunctionpointerwegettheresult:1 AnviJain Updatedon30-Jul-201922:30:26 RelatedQuestions&AnswersFunctionpointertomemberfunctioninC++ DoublePointer(PointertoPointer)inC DeclareaC/C++functionreturningpointertoarrayofintegerfunctionpointers HowtodeclareapointertoafunctioninC? PointerArithmeticinC/C++ NULLpointerinC voidpointerinC C/C++PointerPuzzle? ExplaintheconceptofpointertopointerandvoidpointerinClanguage? HowtodefinepointertopointerinClanguage? CallingamemberfunctiononaNULLobjectpointerinC++ HowtoassignapointertofunctionusingCprogram? ExplaintheconceptofArrayofPointerandPointertoPointerinCprogramming DifferentiatetheNULLpointerwithVoidpointerinClanguage NullPointerExceptioninC# PreviousPage PrintPage NextPage  Advertisements



請為這篇文章評分?