Answers for "make a pointer in c"

C
6

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 \n", i);  // value of i
    printf("j = %d \n", j);  // value of j
    printf("*p = %d \n", p); // the address held by the pointer

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

    printf("i = %d \n", i);   // value of i
    printf("j = %d \n", j);   // value of j
    printf("*p = %d \n", p);  // the address held by the pointer
    printf("&i = %d \n", &i); // address of i
  
  	return 0;
    }
Posted by: Guest on February-13-2022
3

pointers to a function in c

#include <stdio.h>
#include <string.h>

void (*StartSd)(); // function pointer
void (*StopSd)();  // function pointer

void space()
{
    printf("\n");
}

void StopSound() // funtion
{
    printf("\nSound has Stopped");
}

void StartSound() // function
{
    printf("\nSound 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.
}
Posted by: Guest on March-21-2022

Code answers related to "C"

Browse Popular Code Answers by Language