Re: fread fwrite struct



janssenssimon@xxxxxxxxxxx schrieb:
The code given is but a piece of complete code
All the nececary includes are included
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>

witch also have such functions as clrscr() and gotoxy()

<conio.h> and <windows.h> are not standard C -- my compiler
and library combination just does not have them.


The thing I am trying to achief with this code toonhighscores is:
printf of a structure under the titles Naam, Score, Veld

After first having read it from a file.

And the thing I'm trying to achief with the code schrijfweg_highscores
is:
reading a existing binairy file into a structure (linked list).
adding one structure to the linked list
and writing the entire linked list to the overwritten file high.bin

Thank you, this confirms my guesses.


The problem I'm having with this piece of code is:
The first time I run the program, everything works, the reading, the
writing, adding, everything
but if you then close the program, and reopen it, non of the 2 function
work
while I don't see what the difference is with the first the program
runs,...

I actually answered the question: Your problem is that you store
pointers/addresses (HIGH.naam) in a file. As soon as your programme
terminates, these are no longer valid. If you restart the programme and
read in the addresses, there probably is not the same content in the
old location -- worse still, you access memory that does not belong
to your programme. You must store what the pointer points to, the
actual _content_. In this case, a string.
Thus the suggestion to switch from storing your stuff as binary to
storing it as text in a text file -- this can easily be inspected
and errors can be found.


If you want me to sent entire source of the project, please say so,...

No, this is not necessary for _this_ problem.
If you have further problems, try to reduce the version of your
programme you post here to the absolute minimum that still shows
the problem and compiles.

Please quote enough context so that other people know what is
going on -- this gives them a better chance to help you, too.


Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
.



Relevant Pages

  • Re: RSA Challenges
    ... Tell Lionel it's working exploding in addition to a programme. ... Don't even try to dance crossly while you're storing under a ... solar commissioner. ...
    (sci.crypt)
  • Re: Horizon - Shite.
    ... Is there a quota of explosions they have to get into every programme in the series? ... A science documentary about post-humanism and they get 2 explosions in in the first 60 seconds. ... That radio controlled rat has kind of freaked me out since the first time I heard of it - and that was the first time I'd seen it in action. ... But they're entertaining lies. ...
    (uk.media.tv.misc)
  • Re: Why does anyone work for Ryan Air??
    ... required to treat customers like shit; are required to avoid safety ... Ten minutes of the programme already decided it for me. ... Not that I had a bad experience the last time (which was my first time ...
    (uk.legal)
  • Re: $ky using Macrovision now?
    ... I've noticed it on $ky3. ... I tried a recording a week ago and macrovision ruined it. ... Any programme in particular, just to give it a try? ... Wouldnt be the first time. ...
    (uk.media.tv.sky)
  • Re: OT - Queen of Sheba
    ... onwards through the programme to the Rachmaninov Vespers which are ... first time late at night in Gloucester Cathedral in a Three Choirs ... impressive in a cathedral, especially a first hearing. ...
    (uk.media.radio.archers)