Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The exact definition of <code>NULL</code> is implementation-defined; all that's guaranteed about it is that it's a macro that expands to a null pointer constant. In turn, a null pointer constant is "an integral constant expression (5.19) prvalue of integer type that evaluates to zero or a prvalue of type <code>std::nullptr_t</code>." It may or may not be convertible to <code>char</code> or <code>unsigned char</code>; it should only really be used with pointers.</p> <p><code>0</code> is a literal of type <code>int</code> having a value of zero. <code>'\0'</code> is a literal of type char having a value of zero. Either is implicitly convertible to <code>unsigned char</code>, producing a value of zero.</p> <p>It is purely a convention that a string in C and C++ is often represented as a sequence of <code>char</code>s that ends at the first zero value. Nothing prevents you from declaring a char array that doesn't follow this convention:</p> <pre><code>char embedded_zero[] = {'a', '\0', 'b'}; </code></pre> <p>Of course, a function that expects its argument to follow the convention would stop at the first zero: <code>strlen(embedded_zero) == 1;</code>.</p> <p>You can, of course, write a function that takes <code>unsigned char*</code> and follows a similar convention, requiring the caller to indicate the end of the sequence with an element having zero value. Or, you may write a function that takes a second parameter indicating the length of the sequence. You decide which approach better fits your design.</p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    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