EOF character


L

Lew Pitcher

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,

my text file contains many lines of text, some of the text contains EOF
character appended at the end of the text.

if I use:
while (fgets(buffstr, sizeof(buffstr), in_ptr)!=NULL), it will only reach
the first text that contains the EOF character, not to the end of the file.

How can run through the whole file to the end instead, in order to do some
own filtering process?

Open the file in binary mode

file = fopen("filename","rb");


- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBlBduagVFX4UWr64RAj+GAJ413pho75KMip4OcwnSJDbLa7DgAgCeN5Nw
FJRVpSVRuEX/crmcoZNw2Jk=
=Lg7Q
-----END PGP SIGNATURE-----
 
Ad

Advertisements

M

Magix

Hi,

my text file contains many lines of text, some of the text contains EOF
character appended at the end of the text.

if I use:
while (fgets(buffstr, sizeof(buffstr), in_ptr)!=NULL), it will only reach
the first text that contains the EOF character, not to the end of the file.

How can run through the whole file to the end instead, in order to do some
own filtering process?

Thanks.
 
C

Christian Staudenmayer

The fgets() function is used for dealing with textfiles. What you want is the read() function (used together with open()), and you want to supply it with the "b" option for binary (see the manpage of read() for details).

Greetings, Chris
 
M

Magix

Lew Pitcher said:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Open the file in binary mode

file = fopen("filename","rb");



- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFBlBduagVFX4UWr64RAj+GAJ413pho75KMip4OcwnSJDbLa7DgAgCeN5Nw
FJRVpSVRuEX/crmcoZNw2Jk=
=Lg7Q
-----END PGP SIGNATURE-----

Thanks.
 
Ad

Advertisements

M

Martin Ambuhl

Christian said:
The fgets() function is used for dealing with textfiles. What you
want is the read() function (used together with open()), and you want
^^^^ ^^^^
You misspelled both fread() and fopen()
to supply it with the "b" option for binary (see the manpage of
^^^^^^^
You misspelled "your documentation"
read() for details).
^^^^
Again, misspelling fread()
 
Ad

Advertisements


Top