Thread: fwrite

  1. #1


    Why isn't this working?

    fwrite( notes->notes, sizeof( NOTE ), notes->nChildren, dbFile );

    notes->notes is an array of NOTE, the array size being notes->nChildren ...

  2. #2
    Join Date
    Jan 2002
    Don't know. Things to check include return value from fwrite, whether notes->notes is pointing to what you think it should be pointing to, notes->nChildren is a valid value (and that there are that number of NOTES pointed to by notes->notes) and that dbFile is a valid *FILE. Try replacing some of the values with literals and see if that works as expected.

    If you need more help you're going to have to post more code, preferrably a small example that reproduces the problem.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Why don't you check the return result from fwrite(), and also the return result from ferror() following a call to fwrite()
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Alrighty, I've found my problem I think ...

    nChildren = 0, but it is still written as expected...But notes isn't written because it is 0 ..

    Should be able to fix it, thanks ...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem using fwrite
    By kenkoh in forum C Programming
    Replies: 10
    Last Post: 02-16-2008, 09:34 AM
  2. WriteFile and fwrite
    By George2 in forum C Programming
    Replies: 4
    Last Post: 08-10-2007, 04:33 AM
  3. fwrite error: bad address
    By icebabe in forum C Programming
    Replies: 6
    Last Post: 05-06-2006, 06:35 AM
  4. Determining fwrite errors
    By cboard_member in forum C Programming
    Replies: 2
    Last Post: 04-26-2006, 05:30 AM
  5. fwrite file size
    By lambs4 in forum C Programming
    Replies: 4
    Last Post: 04-04-2003, 04:49 PM
Website Security Test