
PSA: You cannot use %.*s to print strings with NUL bytes - gray_-_wolf
Following does not do what most people would expect:<p><pre><code>    +$ cat main.c
    #include &lt;stdio.h&gt;
    
    int main(void) {
     char str[] = { 0, &#x27;a&#x27; };
     printf(&quot;`%.*s&#x27;\n&quot;, sizeof(str), str);
     return 0;
    }
    +$ gcc -o main main.c
    +$ .&#x2F;main 
    `&#x27; 
</code></pre>
This post was triggered by seeing comment suggesting just this (and I can&#x27;t
reply since it is too old). But people should be warned.
======
icedchai
You shouldn't be too surprised: C strings are null terminated.

