Horje
pointers c Code Example
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;
    }
pointers c
#include <stdio.h>
int main()
{
   int *p;
   int var = 10;

   p= &var;

   printf("Value of variable var is: %d", var);
   printf("\nValue of variable var is: %d", *p);
   printf("\nAddress of variable var is: %p", &var);
   printf("\nAddress of variable var is: %p", p);
   printf("\nAddress 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

pointer in C
#include <stdio.h>
int main()
{
   int* pc, c;
   
   c = 22;
   printf("Address of c: %p\n", &c);
   printf("Value of c: %d\n\n", c);  // 22
   
   pc = &c;
   printf("Address of pointer pc: %p\n", pc);
   printf("Content of pointer pc: %d\n\n", *pc); // 22
   
   c = 11;
   printf("Address of pointer pc: %p\n", pc);
   printf("Content of pointer pc: %d\n\n", *pc); // 11
   
   *pc = 2;
   printf("Address of c: %p\n", &c);
   printf("Value of c: %d\n\n", c); // 2
   return 0;
}
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\n", a);
}

// fun_ptr is a pointer to function fun() 
void (*fun_ptr)(int) = &fun;




C

Related
c read binary file Code Example c read binary file Code Example
Wait until an animation finishes - Selenium, Java Code Example Wait until an animation finishes - Selenium, Java Code Example
C first digit of integer Code Example C first digit of integer Code Example
allocating memory for 1Mb text file in C Code Example allocating memory for 1Mb text file in C Code Example
eliminare file in c Code Example eliminare file in c Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8