title: Printf() - printed characters limit
body: <p>I am trying to find what is the allowed limit for the number of characters to be printed by <code>printf()</code> in the C standard. I only found the <a href="http://computer-programming-forum.com/17-c-language/e00e14bab71d1c52.htm">answer</a> in a discussion forum, which indicates <code>INT_MAX</code>.</p>
  
  <p>For example, I checked the following:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  // INT_MAX  2147483647
  
  int main()
  {
      int x=3;
  
      int y = printf("%2147483647d \n\n", x); --&gt; Confirms INT_MAX ?
  
      // If I change the above to 2147483648, y in set to -1
      printf("y = %d\n\n", y);
  
      return 0;
  } 
  </code></pre>
  
  <p>I wanted to ask why is <code>printf()</code> limited by <code>INT_MAX</code> ? Can anyone point out a C standard reasoning or source code reference ? </p>
  
  <p><strong>Edit</strong></p>
  
  <p>The closest answer I found was for <code>fprintf()</code>. At this <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf">link</a>, on page 568, its mentioned (under undefined behavior):</p>
  
  <pre><code>The number of characters or wide characters transmitted by a formatted output
  function (or written to an array, or that would have been written to an array) is 
  greater than INT_MAX.
  </code></pre>
  
  <p>Will the above justify for <code>printf()</code> as well ?</p>