value of pointer in c code example
Example 1: how to print value of pointer in c
#include <stdio.h>
#include <stdlib.h>
void pointerFuncA(int* iptr){
printf("Value: %d\n", *iptr );
printf("Value: %p\n", iptr );
printf("Value: %p\n", &iptr );
}
int main(){
int i = 1234;
int* foo = &i;
pointerFuncA(foo);
return 0;
}
Example 2: how do pointers work in c programmwiz
#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);
pc = &c;
printf("Address of pointer pc: %p\n", pc);
printf("Content of pointer pc: %d\n\n", *pc);
c = 11;
printf("Address of pointer pc: %p\n", pc);
printf("Content of pointer pc: %d\n\n", *pc);
*pc = 2;
printf("Address of c: %p\n", &c);
printf("Value of c: %d\n\n", c);
return 0;
}