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

how to make pointers in c

datatype *var;

variable var actually holds the address of the data(memory where it is stored)
*var lets you access the data stored at that address
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 :: windows forms picturebox change image 
C :: concatenate two strings without standard library in C 
C :: c bubble sort 
C :: c exit 
C :: check whether a number is prime or not in c 
C :: number pattern in c 
C :: getchar in c 
C :: sh: tailwindcss: command not found 
C :: rfid rc522 code 
C :: c print characters 
C :: eliminare file in c 
C :: open with overwrite c 
C :: pointer arithmetic on Arrray in c 
C :: print only last 3 number float in c 
C :: Create the static library libmy.a containing all the functions listed below: 
C :: array of strings c 
C :: %g and %e in c 
C :: size of int in c 
C :: how to take input in c 
C :: c code recursive function to print numbers between two numbers 
C :: 4 byte alignment c code 
C :: https://www.tiktok.com/@kaiwan.99/video/7115521325766069510?is_from_webapp=1&sender_device=pc&web_id=7083069815002449410 
C :: C Character l/O 
C :: winautomation block input not working 
C :: translator program in c 
C :: unigine 
C :: 11*179*.9*1.35 
C :: data breach 
C :: deepak rake 
C :: search and then change string -- strstr and strcpy 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =