This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

fscanf with CCS

I have a text file that I am reading using CCS using the function fscanf(). I can only read couple of values in the txt file and after that the fscanf function does not successfully read data from the txt anymore.

Here is the fscanf statement: SCAN_COUNT = fscanf(file, "%f", &value);

 

Questions:

1) Shouldn't fscanf work?

2) Is there a document identifying what standard C functions that can be used with CCS.

3) Is there a more effective way to read a file (large memory size) from the computer into the processor memory using CCS?

 

Thanks!

 

 

  • Hi,

    hdp said:
    1) Shouldn't fscanf work?

    If the function fscanf does not find the format compatible with what is in the file, it will not work.  So if it is reading integer (%d), it will work as long as the file has numbers that are spaced - when it finds something wrong with the format, fscanf will stop reading. The same will happen when reading the characters %c - if it does not find the proper character format, it will stop reading. So this might be one of your problems - what is in the file is not in one proper format. 

    For formats, you can look for "length modifiers" in this page (not a TI page):  

    http://www.opengroup.org/onlinepubs/009695399/functions/scanf.html

    hdp said:
    2) Is there a document identifying what standard C functions that can be used with CCS.

    TI does not provide this documentation because we do not own the standard C. You can search the Internet or try buying a book. 

    hdp said:
    3) Is there a more effective way to read a file (large memory size) from the computer into the processor memory using CCS?

    I would suggest you to use fread - it does not have the problems with format that fscanf has.