Search
 
SCRIPT & CODE EXAMPLE
 

C

pointer to function 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

pointer in c

#include <stdio.h>

int main()
{
    int j;
    int i;
    int *p; // declare pointer

    i = 7;
    p = &i; // The pointer now holds the address of i
    j = *p;

    printf("i = %d 
", i);  // value of i
    printf("j = %d 
", j);  // value of j
    printf("*p = %d 
", p); // the address held by the pointer

    *p = 32; // asigns value to i via the pointer

    printf("i = %d 
", i);   // value of i
    printf("j = %d 
", j);   // value of j
    printf("*p = %d 
", p);  // the address held by the pointer
    printf("&i = %d 
", &i); // address of i
  
  	return 0;
    }
Comment

pointer in C

#include <stdio.h>
int main()
{
   int* pc, c;
   
   c = 22;
   printf("Address of c: %p
", &c);
   printf("Value of c: %d

", c);  // 22
   
   pc = &c;
   printf("Address of pointer pc: %p
", pc);
   printf("Content of pointer pc: %d

", *pc); // 22
   
   c = 11;
   printf("Address of pointer pc: %p
", pc);
   printf("Content of pointer pc: %d

", *pc); // 11
   
   *pc = 2;
   printf("Address of c: %p
", &c);
   printf("Value of c: %d

", c); // 2
   return 0;
}
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

pointers c

#include <stdio.h>
int main()
{
   int *p;
   int var = 10;

   p= &var;

   printf("Value of variable var is: %d", var);
   printf("
Value of variable var is: %d", *p);
   printf("
Address of variable var is: %p", &var);
   printf("
Address of variable var is: %p", p);
   printf("
Address of pointer p is: %p", &p);
   return 0;
}
#output
#Value of variable var is: 10
#Value of variable var is: 10
#Address of variable var is: 0x7fff5ed98c4c
#Address of variable var is: 0x7fff5ed98c4c
#Address of pointer p is: 0x7fff5ed98c50

Comment

pointer in C

#include<stdio.h>
#include<stdlib.h>
main()
{
    int *p;
    p=(int*)calloc(3*sizeof(int));
    printf("Enter first number
");
    scanf("%d",p);
    printf("Enter second number
");
    scanf("%d",p+2);
    printf("%d%d",*p,*(p+2));
    free(p);
}
Comment

PREVIOUS NEXT
Code Example
C :: pointers c 
C :: pthread_create 
C :: c declare float 
C :: perfect numbers in c 
C :: calculate max of three numbers using ternary operator in c 
C :: what is implicit typecasting 
C :: C printf Declaration 
C :: website how to solve c programming questions 
C :: Recommended compiler and linker flags for GCC 
C :: install zoom on ubuntu 
Dart :: dart random number 
Dart :: flutter generate random color 
Dart :: flutter label alignment top 
Dart :: How to center AlertDialog FlatButton in Flutter 
Dart :: switch to another flutter channel eg. $ flutter channel beta $ flutter channel stable 
Dart :: flutter appbar icon 
Dart :: regex numbers only dart 
Dart :: flutter chip labelstyle 
Dart :: mark as deprecated dart 
Dart :: flutter lock orientation 
Dart :: flutter chip padding 
Dart :: dart list to json 
Dart :: flutter flotingactionbutton extend 
Dart :: flutter listtile disable 
Dart :: flutter gesturedetector 
Dart :: flutter iOS & Android chnage package name & app name 
Dart :: dart filter list 
Dart :: dart for each indexed 
Dart :: dart print item # of a list 
Dart :: listview flutter give padding to list bottom 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =