title: Writing to stderr in x86 assembly
body: <p>I'm pretty new to assembly, and I was wondering how one would write output to stderr.  I know you can access C Standard Library functions, like printf, to print to the console.  But I can't figure out how to print to stderr.  I was trying to use fprintf, but I'm just sort of guessing at arguments, and I have no idea how to specify stderr as the file pointer. Thanks.</p>
  
  <p>Edit: As per sehe's suggestion, I tried this:</p>
  
  <pre><code>.586
  .model small,c
  .stack 100h
  
  .data
  msg db 'test', 0Ah
  
  .code
  includelib MSVCRT
  extrn fprintf:near
  extrn exit:near
  
  public main
  main proc
      push    offset msg
      push    2       ;specify stderr
      call    fprintf ;print to stderr
      push    0
      call    exit    ;exit status code 0
  
  main endp
  
  end main
  </code></pre>
  
  <p>But it just caused my program to crash. Any other advice?</p>