Answers for "c pointer &"

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
1

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
Posted by: Guest on February-03-2022

Code answers related to "C"

Browse Popular Code Answers by Language