title: How to avoid runtime error when using va_arg() in C
body: <p>I'm trying to make some function that will do similar effect like <code>printf</code>.</p>
  
  <p>Before I'm making these function I'm learning about <code>va_list</code>, <code>va_start</code>, <code>va_arg</code>...
  I've made a simple code:</p>
  
  <pre><code>int main()
  {
      success("Hello", 356);
  }
  void success(char* format, ...)
  {
      va_list list;
      char *String;
      va_start(list,format);
      String = va_arg(list,char*);
      printf("%s",String);
      va_end(list);
      getchar();
  }
  </code></pre>
  
  <p>This code <strong>should</strong> fail with runtime error (sending integer while expecting to get string).</p>
  
  <p>I'm trying to avoid the runtime error, I want to print some error message if <code>va_arg</code> fails and exit the program but I don't know how to check if <code>va_arg</code> failed. </p>
  
  <p>I've searched a solution but I couldn't find any. 
  I can't use try->catch because I'm programming in C.</p>