Thread: Help! Inserting a character into file

  1. #16
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > I have found that the magical, (or, at least mystical) incantation with fseek()
    Yeah - my bad
    I assumed that since he was overwriting the next character an fseek() was not necessary.

    But it is - I've read the manual
    Reads and writes may be intermixed on read/write streams in any order.
    Note that ANSI C requires that a file positioning function intervene
    between output and input, unless an input operation encounters end‐of‐
    file. (If this condition is not met, then a read is allowed to return
    the result of writes other than the most recent.) Therefore it is good
    practice (and indeed sometimes necessary under Linux) to put an fseek
    or fgetpos operation between write and read operations on such a
    stream. This operation may be an apparent no‐op (as in fseek(..., 0L,
    SEEK_CUR) called for its synchronizing side effect.

  2. #17
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Prelude
    >Try this
    Also, since the idea is to replace the '&' character, the first seek needs to go backward by one character to account for the fact that the '&' character has already been read by fgetc.
    No it wasn't:

    Quote Originally Posted by Ariod
    I'm trying to add 'q' after each ampersand (replacing the character that is already there)
    See how confusing their message combine with the title was?

    [edit] Bah. I guess I should have read the entire thread... It was still worded poorly. [/edit]

    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Newbie homework help
    By fossage in forum C Programming
    Replies: 3
    Last Post: 04-30-2009, 04:27 PM
  2. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  3. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  4. Inventory records
    By jsbeckton in forum C Programming
    Replies: 23
    Last Post: 06-28-2007, 04:14 AM
  5. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM