title: Why does printf specifier format %n not work?
body: <p>This is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(void) {
      int n;
  
      fprintf(stdout, "Hello%n World\n", &amp;n);
      fprintf(stdout, "n: %d\n", n);
  
      return 0;
  } 
  </code></pre>
  
  <p>This is my output:</p>
  
  <pre><code>Hellon: 0
  </code></pre>
  
  <ol>
  <li>Why does the <code>fprintf</code> format specifier <code>"%n"</code> not work? </li>
  <li>Why is the string to be printed interrupted?</li>
  </ol>
  
  <p><strong><em>ISO/IEC 9899:201x C11 - 7.21.6.1 - The fprintf function</em></strong></p>
  
  <blockquote>
    <p>The conversion specifiers and their meanings are:</p>
    
    <p><strong>(...)</strong></p>
    
    <p><strong>%n</strong> The argument shall be a pointer to signed integer into which is written the number of characters written to the output stream so far
    by this call to fprintf. No argument is converted, but one is
    consumed. If the conversion specification includes any flags, a field
    width, or a precision, the behavior is undefined. ...</p>
    
    <p><strong>(...)</strong></p>
  </blockquote>
  
  <p>This is my compiler version used on Code::Blocks:</p>
  
  <pre><code>Using built-in specs.
  COLLECT_GCC=gcc
  COLLECT_LTO_WRAPPER=C:/Program\ Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev
  0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe
  Target: x86_64-w64-mingw32
  Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --bu
  ild=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysr
  oot=/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64 --enable-shared --enable
  -static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdc
  xx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-
  lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --
  enable-version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx
  -debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls
   --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=noco
  na --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/p
  rerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86
  _64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-s
  tatic --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgv
  ersion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=https:/
  /sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x
  86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x
  86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/
  include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6
  -rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include
   -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/
  mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prere
  quisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw
  32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-posix-seh-
  rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L
  /c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
  Thread model: posix
  gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)
  </code></pre>