c print pointer code example
Example 1: c printing char pointer
#include <stdio.h>
int main()
{
char * str = "Hello";
printf("%s\n", str);
return 0;
}
Example 2: 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 3: how to print the address of a pointer in c
int a = 42;
printf("%p\n", (void *) &a);