how to print 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 to print a pointer array in c
#include <stdio.h>
int main() {
int data[5];
printf("Enter elements: ");
for (int i = 0; i < 5; ++i)
scanf("%d", data + i);
printf("You entered: \n");
for (int i = 0; i < 5; ++i)
printf("%d\n", *(data + i));
return 0;
}