--- In [email protected], Rayne <[EMAIL PROTECTED]> wrote:
>
> Hi all,
> I'm having programs reading from files. 
> 
> I have a text file "files.txt" that contains the names
> of the files to be opened, i.e. the contents of
> files.txt are
> 
> Homo_sapiens.fa
> Rattus_norvegicus.fa
> 
> (They are FA files that can be opened in any text
> editor.)
> 
> Each of the FA files contains a number in the first
> line and a string of characters (A,T,G or C). For
> example, the Homo_sapiens.fa file would contain
> 
> 16571
> GATCACAGGTCTATCACCCTATTAACCACTCACGGGAGCTCTCCATGCATTTGGTATTTT
> CGTCTGGGGGGTGTGCACGCGATAGCATTGCGAGACGCTGGAGCCGGAGCACCCTATGTC
> GCAGTATCTGTCTTTGATTCCTGCCTCATTCTATTATTTATCGCACCTACGTTCAATATT
> ACAGGCGAACATACCTACTAAAGTGTGTTAATTAATTAATGCTTGTAGGACATAATAATA
> 
> and so on, with 16571 A,T,G or Cs.
<snip>

I'm not the biggest specialist when it comes to fscanf(), but I simply
don't use it due to having had too much trouble using different
compilers on different OS versions (though this is really a long time
ago). What I usually do is almost always utilising fgets(); just keep
in mind that every line that has been read completely will be
terminated by a '\n' character which you will want to cut off.

fgets() is safer to use in my opinion.

Also, as far as I recall (please correct me anyone if I'm wrong)
fscanf() returns the number of items read from the input file; it will
not return EOF as EOF is a macro to determine end of input if you read
input character by character. If you want to check for the end of a
FILE*, you will have to use feof().

Regards,
Nico

Reply via email to