You want to use %p
to print a pointer. From the spec:
p
The argument shall be a pointer tovoid
. The value of the pointer is converted to a sequence of printing characters, in an implementation-defined manner.
And don’t forget the cast, e.g.
printf("%p\n",(void*)&a);
More Related Contents:
- Correct format specifier to print pointer or address?
- What exactly is the array name in c?
- What exactly is a C pointer if not a memory address?
- How to printf a memory address in C
- Why can’t I treat an array like a pointer in C?
- Is it possible to store the address of a label in a variable and use goto to jump to it?
- what is meant by (void *) variable and (void *) & variable in C [closed]
- I had issue in below mention program to assign a value to the pointer.String concatenation Program( *s1=*s2) [closed]
- Segmentation Fault in C(core dumped)–simple pointer [closed]
- Crash or “segmentation fault” when data is copied/scanned/read to an uninitialized pointer
- How come an array’s address is equal to its value in C?
- What is the difference between char array and char pointer in C?
- How do I understand complicated function declarations?
- How can I allocate memory and return it (via a pointer-parameter) to the calling function?
- C pointers : pointing to an array of fixed size
- Array to pointer decay and passing multidimensional arrays to functions
- Why does this code segfault on 64-bit architecture but work fine on 32-bit?
- C: Which character should be used for ptrdiff_t in printf?
- Why doesn’t scanf need an ampersand for strings and also works fine in printf (in C)?
- Pointer vs array in C, non-trivial difference
- Passing arrays and matrices to functions as pointers and pointers to pointers in C
- Is it good practice to free a NULL pointer in C? [duplicate]
- change pointer passed by value
- Accesing a 2D array using a single pointer
- Triple pointers in C: is it a matter of style?
- C: pointer to array of pointers to structures (allocation/deallocation issues)
- How to explain C pointers (declaration vs. unary operators) to a beginner?
- Why does NSError need double indirection? (pointer to a pointer)
- What is the real difference between Pointers and References?
- Does C have an equivalent of std::less from C++?