Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>if I write this, is it right?</p> </blockquote> <p>No. This is not right. For <code>%p</code> specifier you must have to cast it to <code>void *</code>. Your compiler should give <a href="http://ideone.com/1UYBO0" rel="nofollow noreferrer">warning</a> about this: </p> <pre><code>warning: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘int **’ [-Werror=format=] </code></pre> <p>Read this <a href="https://stackoverflow.com/a/17506236/2455888">answer</a>. It says that: </p> <p><em>The <code>%p</code> format requires an argument of type <code>void*</code>. If pointers of type <code>int*</code> and <code>int(*)[10]</code> have the same representation as <code>void*</code> and are passed as arguments in the same way, as is the case for most implementations, it's likely to work, but it's not guaranteed. You should explicitly convert the pointers to <code>void*</code></em> </p> <h2>Draft n1570; 7.21.6 Formatted input/output functions:</h2> <blockquote> <p>p The argument shall be a pointer to <code>void</code>. The value of the pointer is converted to a sequence of printing characters, in an implementation-defined manner. </p> </blockquote> <hr> <blockquote> <p>but theses two statements don’t return the same value if I put both of them in the program. </p> </blockquote> <p>Yes,it will not return the same value. <code>P</code> will give you the value of address of the variable <code>p</code> points to (pointee) while <code>&amp;p</code> will give you the value of the address of pointer <code>p</code> itself. Cast <code>&amp;p</code> to <code>void *</code>. </p> <pre><code>printf("memory location of ptr: %p\n", (void *)&amp;p); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload