Thread: What is callback formula in C?

  1. #1
    kotin
    Join Date
    Oct 2009
    Posts
    132

    What is callback formula in C?

    Hi ,

    I have studies some material in google. But i confused by reading all those materials.

    Actually any one can explain me the simple logic for Callback?

    I know that callback means recruiting an Employee after layoff :-). How this meaning is related to "C" call back functions?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Use qsort to sort an array of integers. The comparison function that you use is a callback function.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    kotin
    Join Date
    Oct 2009
    Posts
    132
    Hi light,

    you mean to say qsort and comparison function both are executables. so a callback is a reference to executable code(comparison function executable code), that is passed as an argument to other code (qsort code) ?

    am i correct?

    Note:
    1. from wikipedia "In computer programming, a callback is a reference to executable code, or a piece of executable code, that is passed as an argument to other code. This allows a lower-level software layer to call a subroutine (or function) defined in a higher-level layer."

  4. #4
    kotin
    Join Date
    Oct 2009
    Posts
    132
    Hi,

    can any one give small example for the statement on callback as "A callback is often back on the level of the original caller" ?

    I did not understand regarding that statement.

    Thanks in advance.

  5. #5
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by nkrao123@gmail.
    you mean to say qsort and comparison function both are executables.
    We could say that all functions are executable, so: of course.

    Quote Originally Posted by nkrao123@gmail.
    so a callback is a reference to executable code(comparison function executable code), that is passed as an argument to other code (qsort code) ?

    am i correct?
    In this context, we could just say that a callback is a function that is passed as a function pointer argument to another function from which it is called.

    Quote Originally Posted by nkrao123@gmail.
    can any one give small example for the statement on callback as "A callback is often back on the level of the original caller" ?
    In other words, the article claims that a callback is often defined in the same module as the original caller.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. callback function
    By koszta in forum C Programming
    Replies: 2
    Last Post: 02-23-2009, 12:51 PM
  2. callback in a class, what do I do?
    By Yarin in forum C++ Programming
    Replies: 5
    Last Post: 08-17-2007, 11:11 AM
  3. Callback functions
    By linuxdude in forum C Programming
    Replies: 2
    Last Post: 01-03-2004, 06:23 PM
  4. Callback functions
    By WebmasterMattD in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2003, 07:45 PM
  5. help!! callback in dll....
    By kimcs in forum Windows Programming
    Replies: 4
    Last Post: 06-30-2003, 07:47 AM