i have googled a lot to find out the difference between normal function and callback function. Unfortunatley I could not understand. if we have to call a function inside another function, what is usefulness of passing it as a parameter to the function by using function pointers? Is it possible to call the function passed as a parameter in the form of function pointers somewhere outside the function, in which it is passed as parameter? if yes, please give me a rough idea of its implementation. Thanks
1 Answer
Say you have a function that does some prolonged operation, like send email. You don't want to wait for it to finish, so you give it a callback function that will invoke once it's done. That's a major use of callbacks - notification of asynchronous operations. There are other uses.
1 Comment
muhammad ahsan
i actually want to implement callback function through function pointers for the calculation of CRC through Direct Memory Access (DMA). Í have status bits to check whether DMA has successfully completed the data trnasfer or not? So, if I implement it in a way to check the status bits and once transfer is completed and status bits get the desired values, I can call my function to do further things. could you please differentiate between your proposal and my understanding.