title: char type in va_arg
body: <p>I have the following function which writes passed arguments to a binary file.</p>
  
  <pre><code>void writeFile(FILE *fp, const int numOfChars, ...)
  {
     va_list ap;
     va_start(ap, numOfChars);
     for(int i = 0; i &lt; numOfChars; i++)
     {
        const char c = va_arg(ap, char);
        putc(c, fp);
     }
     va_end(ap);
  }
  </code></pre>
  
  <p>Upon compiling, I get the following warning from the compiler</p>
  
  <pre><code> warning: second argument to 'va_arg' is of promotable type 'char'; this va_arg
        has undefined behavior because arguments will be promoted to 'int' [-    Wvarargs]
  </code></pre>
  
  <p>Now as I understand it, C wants to promote char type to int. Why does C want to do this? Second, is the best solution to cast the int back to a char? </p>