Search
 
SCRIPT & CODE EXAMPLE
 

C

callback c++ c

//Define a type for the callback signature,
//it is not necessary, but makes life easier

//Function pointer called CallbackType that takes a float
//and returns an int
typedef int (*CallbackType)(float);  


void DoWork(CallbackType callback)
{
  float variable = 0.0f;

  //Do calculations

  //Call the callback with the variable, and retrieve the
  //result
  int result = callback(variable);

  //Do something with the result
}

int SomeCallback(float variable)
{
  int result;

  //Interpret variable

  return result;
}

int main(int argc, char ** argv)
{
  //Pass in SomeCallback to the DoWork
  DoWork(&SomeCallback);
}
Comment

PREVIOUS NEXT
Code Example
C :: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration] 
C :: c memset 
C :: strcasecmp c 
C :: 2 bytes integer c 
C :: Convert mpg / mp4 to gif with ffmpeg 
C :: c radians 
C :: c programming how to force stop the programme 
C :: c recursion func revers number 
C :: addition of two numbers in c 
C :: check if string is the same c 
C :: Example of Implementation of a pointer to an array in C: 
C :: bootstrap 4 forms 
C :: how to compareTo in java 
C :: malloc basics 
C :: Bitwise Operators in C language 
C :: how to change background color in c programming 
C :: c include delay 
C :: KneesDev 
C :: how to change file permissions in C language 
C :: c str add int 
C :: c defined 
C :: scan c 
C :: C Input and Output Array Elements 
C :: Regex to match any character being repeated more than 10 times 
C :: linux_reboot_magic2 
C :: entity framework core discard changes 
C :: run steam as root 
C :: Combine two sentences into one langage c 
C :: e sharm card jobkhozo.com 
C :: c to assembly converter online 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =