callback c 2b 2b c

Solutions on MaxInterview for callback c 2b 2b c by the best coders in the world

showing results for - "callback c 2b 2b c"
Malone
29 Jul 2017
1//Define a type for the callback signature,
2//it is not necessary, but makes life easier
3
4//Function pointer called CallbackType that takes a float
5//and returns an int
6typedef int (*CallbackType)(float);  
7
8
9void DoWork(CallbackType callback)
10{
11  float variable = 0.0f;
12
13  //Do calculations
14
15  //Call the callback with the variable, and retrieve the
16  //result
17  int result = callback(variable);
18
19  //Do something with the result
20}
21
22int SomeCallback(float variable)
23{
24  int result;
25
26  //Interpret variable
27
28  return result;
29}
30
31int main(int argc, char ** argv)
32{
33  //Pass in SomeCallback to the DoWork
34  DoWork(&SomeCallback);
35}
36
similar questions
queries leading to this page
callback c 2b 2b c