Skip to main content
csutter
Associate
February 19, 2014
Question

Write to textfile

  • February 19, 2014
  • 3 replies
  • 671 views
Posted on February 19, 2014 at 09:35

Hi 

I'm trying to write some values to a textfile but without success. I work with the IAR Workbench. Bellow the code which I found also in the Arm User Guide:

#include <stdio.h>

FILE *f; f = fopen (''Test.txt'',''r''); /* Open a file from default drive. */ if (f == NULL) { printf (''File not found!\n''); }

The error is FILE and f undefined Can anybody help me what I'm doing wrong?Regards

    This topic has been closed for replies.

    3 replies

    chen
    Associate II
    February 19, 2014
    Posted on February 19, 2014 at 11:04

    Hi

    ''

    The error is FILE and f undefined Can anybody help me what I'm doing wrong?''

    You are working in an embedded environment where there is no 'file' definition as standard.

    It is up to the developer to define/create the file definition.

    In other words - what/where is the file stream going to be directed?

    Where is the text file going to be stored (SD card, USB memory stick, NV RAM etc)

    What filing system is there?

    csutter
    csutterAuthor
    Associate
    February 19, 2014
    Posted on February 19, 2014 at 12:51

    Hi 

    Ok thanks for your answer. I was wrong with my thinking:)

    regards

    Andrew Neil
    Super User
    February 20, 2014
    Posted on February 20, 2014 at 20:33

    ''I was wrong with my thinking''

    Yes - but all is not lost!

    There are plenty of examples of using file systems on microcontrollers; eg, with SD Cards.

    However, you might do well to start with some more basic, entry-level projects...

    A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.