#include <stdio.h>
#include <string.h>
void (*StartSd)(); // function pointer
void (*StopSd)(); // function pointer
void space()
{
printf("
");
}
void StopSound() // funtion
{
printf("
Sound has Stopped");
}
void StartSound() // function
{
printf("
Sound has Started");
}
void main()
{
StartSd = StartSound; // Assign pointer to function
StopSd = StopSound; // Assign pointer to function
(*StartSd)(); // Call the function with the pointer
(*StopSd)(); // Call the Function with the pointer
space();
StartSd(); // Call the function with the pointer
StopSd(); // Call the function with the pointer
space();
StartSound(); // Calling the function by name.
StopSound(); // Calling the function by name.
}
// Basic syntax
ret_type (*fun_ptr)(arg_type1, arg_type2,..., arg_typen);
// Example
void fun(int a)
{
printf("Value of a is %d
", a);
}
// fun_ptr is a pointer to function fun()
void (*fun_ptr)(int) = &fun;