Search
 
SCRIPT & CODE EXAMPLE
 

C

pointers to a function in c

#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.
}
Comment

function pointer in c

// 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;
Comment

PREVIOUS NEXT
Code Example
C :: print command for rust unit-test 
C :: declare variables arduino 
C :: clear screen in c 
C :: link list c 
C :: Palindrome number in c program 
C :: how to get file size in c 
C :: multiplication of matrix in c 
C :: Installing Tailwind 
C :: malloc c 
C :: How to copy one string into another in C 
C :: imprimir matriz 
C :: . Simulate MVT and MFT. 
C :: square in c 
C :: Happy birthday in C 
C :: c pause for 1 second 
C :: define constant c 
C :: what is the use of malloc in c 
C :: declaration of string in c 
C :: iterating through a linked list 
C :: national festivals of india in hindi 
C :: fifo page algorithm in C 
C :: String to Integer (atoi) 
C :: main prototype 
C :: c create array 
C :: extended euclidean algorithm to find x and y 
C :: YOUNG SEX PARTY underground collection 
C :: gtk widget change window title 
C :: Array in element from lowest 
C :: copy a number of characters to another string in c without standard library 
C :: profile time bash script 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =