title: What Is Needed To Use fopen() On An Embedded System?
body: <p>I am quite new to the FILE family of functions that the standard C library provides.</p>
  
  <p>I recently stumbled across <code>fopen()</code> and the similar functions after researching how <code>stdout</code>, <code>stdin</code> and <code>stderr</code> work alongside functions like <code>printf()</code>.</p>
  
  <p>I was wondering, what is needed to use <code>fopen()</code> on an embedded system (which doesn't necessarily have operating system support). After reading more about it, is seems like a cool thing to do on more powerful embedded systems to hook into say, a UART/SPI interface, so that calling <code>printf()</code> would print data out of the UART. Simarly, you could read data from a UART buffer by calling <code>scanf()</code>.</p>
  
  <p>This would also increase portability! (code written for say, Linux, would be easier to port if <code>printf()</code> was supported). You could also print debug data to a file if it was running in a production environment, and read from it later.</p>
  
  <p>Can you just use <code>fopen()</code> on a bare-bones embedded system? If so who/where/when is the "FILE" then created (as far as I now, <code>fopen()</code> does not <code>malloc()</code> space for the file, nor do you specify how much)? Or do you need a operating system with FAT file support. If so, would something like <a href="http://ultra-embedded.com/?fat_filelib" rel="nofollow">http://ultra-embedded.com/?fat_filelib</a> work? Would using FreeRTOS help at all?</p>