EOF character

Discussion in 'C Programming' started by Lew Pitcher, Nov 12, 2004.

  1. Lew Pitcher

    Lew Pitcher Guest

    -----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-----
     
    Lew Pitcher, Nov 12, 2004
    #1
    1. Advertisements

  2. Lew Pitcher

    Magix Guest

    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.
     
    Magix, Nov 12, 2004
    #2
    1. Advertisements

  3. 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
     
    Christian Staudenmayer, Nov 12, 2004
    #3
  4. Oops, I've got that all wrong. My bad, it's 3 AM. :)

    Greetings, Chris.
     
    Christian Staudenmayer, Nov 12, 2004
    #4
  5. Lew Pitcher

    Magix Guest

    Thanks.
     
    Magix, Nov 12, 2004
    #5
  6. ^^^^ ^^^^
    You misspelled both fread() and fopen()
    ^^^^^^^
    You misspelled "your documentation"
    ^^^^
    Again, misspelling fread()
     
    Martin Ambuhl, Nov 12, 2004
    #6
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.