Callbacks in C - Tutorialspoint

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

The callback is basically any executable code that is passed as an argument to other code, that is expected to call back or execute the ... 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 CallbacksinC CServerSideProgrammingProgramming Thecallbackisbasicallyanyexecutablecodethatispassedasanargumenttoothercode,thatisexpectedtocallbackorexecutetheargumentatagiventime.Wecandefineitinotherwordslikethis:Ifthereferenceofafunctionispassedtoanotherfunctionargumentforcalling,thenitiscalledthecallbackfunction.InCwehavetouseafunctionpointertocallthecallbackfunction.Thefollowingcodeisshowinghowthecallbackfunctionisdoingitstask.ExampleCode#include voidmy_function(){   printf("Thisisanormalfunction."); } voidmy_callback_function(void(*ptr)()){   printf("Thisiscallbackfunction.\n");   (*ptr)(); //callingthecallbackfunction } main(){   void(*ptr)()=&my_function;   my_callback_function(ptr); }OutputThisiscallbackfunction. Thisisanormalfunction. VrundeshaJoshi Updatedon30-Jul-201922:30:25 RelatedQuestions&AnswersJavaScriptCallbacks PHPCallbacks/Callables UseofCallbacksinLayeredArchitecture PromisesCallbacksAndAsync/Await HowcanForgottentimersorcallbackscausememoryleaksinJavaScript? WhataretheargumentstoTkintervariabletracemethodcallbacks? strcoll()inC/C++ fseek()inC/C++ strcpy()inC/C++ strcmp()inC/C++ isless()inC/C++ islessgreater()inC/C++ PointersinC/C++ isgreater()inC/C++ modf()inC/C++ PreviousPage PrintPage NextPage  Advertisements



請為這篇文章評分?