techpreparation-homepage

Home  Interview Questions  Aptitude Questions  Tutorials  Placement Papers  Search  Resume Guide  Soft Skills  Video  Forum  Blog


Technical Interview Questions

.Net Interview Questions
C++ Interview Questions
Unix Interview Questions
                              .........More

Download e-Books
C Interview Questions e-book

Aptitude Interview Questions
C/C++ Aptitude Questions
C Aptitude Questions
                              .........More

Online Quiz
C Online Quiz
C++ Online Quiz
                              .........More

 

 

  

  Home > C Interview Questions >

How do you print an address?

The safest way is to use printf() (or fprintf() or sprintf()) with the %P specification. That prints a void pointer (void*). Different compilers might print a pointer with different formats.

Your compiler will pick a format that’s right for your environment.
If you have some other kind of pointer (not a void*) and you want to be very safe, cast the pointer to a void*:

printf( %Pn, (void*) buffer );

 

Have a Question ? post your questions here. It will be answered as soon as possible.