Re: Having problem with my FRead in my program



Those would not be my first choice of functions for reading the file, but
they should work.

CreateFile, WriteFile and ReadFile might give you more information for
debugging.

How do you open the file?

--
Bruce Eitman (eMVP)
Senior Engineer
beitman AT applieddata DOT net

Applied Data Systems
www.applieddata.net
An ISO 9001:2000 Registered Company
Microsoft WEP Gold-level Member


"Jean Nicolas Turcotte" <jn_turcotte_microstep@xxxxxxxx> wrote in message
news:e8HtE%23UNFHA.1172@xxxxxxxxxxxxxxxxxxxxxxx
> I am having problem reading some data in a file !
>
> I know this isn't the place to post and ask code like that but I have
> been searching for my problem for quite a time now and I don't know
> where else to post(if there is a better newgroup for this, please let me
> know). I am sure it's a little something that I just can't see.
>
> My file is a binary file. The first part of the file is a header with
> contains information about the file.
> Then everything under is another type of structure which contains logs
> of data.
>
> I have no problem writing and reading the first part (header), I don't
> think I have a problem writing the second part (the logs)
> But when I come to read the logs (second part) it doesn't work.
>
> The fread always return 0 and ferror doesn't return any error type.
>
> I need to specify that I am coding on a WCE platform 3.0 but that
> shouldn't make any difference here for reading and writing to a file.
>
>
>
>
> ****** Here is how I read my logs ******
> (logdata is a pointer to a structure of logs, and ScaleFile is a
> FilePointer to my already opened file)
>
>
> int CScaleFile::getNextLog(FLog *logdata)
> {
> int count = 0;
>
> fflush(ScaleFile);
> count = fread( logdata, sizeof(*logdata), 1, ScaleFile );
>
> if ( !ferror( ScaleFile ) ) {
>
> fflush(ScaleFile);
> return 0;
>
> } else {
> if ( feof(ScaleFile) != 0 )
> return -2; //An error other than EndOfFile occurred
> else
> return -1; //EOF occurred
> }
>
> }
>
>
>
>
>
> ****** This is how I write these logs ******
>
> bool CScaleFile::addLog(FLog *log)
> {
> if (GetIsOpen() ) { //If the file is open
>
> fflush(ScaleFile);
> fseek( ScaleFile, 0, SEEK_END);
>
> if ( fwrite( log, sizeof(*log), 1, ScaleFile) == 0 ) {
>
> return false;
>
> } else {
>
> fflush(ScaleFile);
> this->nbLog = this->getNbLog() + 1;
> return true;
>
> }
>
> } else
> return false;
>
> }
>
>
>
>
> ****** This is how I read my header *******
>
> bool CScaleFile::readHeader()
> {
> int count = 0;
>
> fseek( ScaleFile, 0, SEEK_SET );
> count = fread( &Header, sizeof(Header), 1, ScaleFile );
>
> if ( !ferror( ScaleFile ) ) {
>
> fflush(ScaleFile);
> return true;
>
> } else {
> return false;
> }
>
> }
>
>
>
>
> As you can see my ReadHeader and my ReadLogs are quite the same type of
> function, so I don't understand why it doesn't work here.
>
> If someone see what I am doing wrong, I would like to know cause I don't
> know anymore where to check for possible errors.
>
> Thank You !


.



Relevant Pages

  • Having problem with my FRead in my program
    ... Then everything under is another type of structure which contains logs of data. ... I have no problem writing and reading the first part, I don't think I have a problem writing the second part ... (logdata is a pointer to a structure of logs, and ScaleFile is a FilePointer to my already opened file) ... {int count = 0; fseek; ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: Saving passwords without prompting
    ... > Ralph Wade Phillips wrote: ... >> wait, don't finish reading this, go change it NOW. ... If he isn't, and the logs aren't available, I'd ... > If you know whomever you suspect is reading your mails, ...
    (uk.comp.homebuilt)
  • Re: Separating AD Log and Data Files...Benefits out weigh the costs?
    ... OS on RAID1 (a lot of reading and writing) ... For the DCs in your scenario it should be more than enough to have: ... OS, AD DB, AD LOGS, AD SYSVOL on RAID1 ...
    (microsoft.public.windows.server.active_directory)
  • Re: Firefox overtakes IE6
    ... By reading the logs of one particular site, ... then green must be a vague term. ... If web stats are 'vague', ...
    (uk.people.silversurfers)
  • Re: Saving passwords without prompting
    ... But that won't keep anyone else from accessing your account if they know what the password is. ... Unless a network admin somewhere along the mails route takes a look, or the POP3 box is brute forced,, your email should be pretty safe. ... If he isn't, and the logs aren't available, I'd suggest planting a link to a website that logs are available for. ... If you know whomever you suspect is reading your mails, it should be easy enough to get them to visit a particular link.. ...
    (uk.comp.homebuilt)