title: Format specifer in C++
body: <p>I'am trying to understand a C++ compiler behaviour. Here is a code, where I made two mistakes intentionally:</p>
  <ol>
  <li>forgot <code>%ld</code> format specifier in <code>scanf</code> and just wrote <code>%</code>.</li>
  <li>added unknown format specifer for <code>printf</code> - wrote <code>%l</code> instead of <code>%ld</code> for <code>long</code> datatype.</li>
  </ol>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdio&gt;
  using namespace std;
  
  int main() {
      // Complete the code.
      int a; long b; char c; float d; double e;
      scanf(&quot;%d % %c %f %lf&quot;, &amp;a, &amp;b, &amp;c, &amp;d, &amp;e);
      printf(&quot;%d \n%l \n%c \n%f \n%lf&quot;, a, b, c, d, e);
      return 0;
  }
  </code></pre>
  <p>There is a snippet above, that successfully compiles and shows warnings. Why it didn't produce an error for unknown/missing C++ format specifier? How it was compiled?</p>
  <p>Output:
  <a href="https://i.stack.imgur.com/evOHw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/evOHw.png" alt="Input data and strange output after mistakes" /></a></p>