🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11686

how does fwrite i fread works ?

#11686
From: ScOe
Date: Sun, 18 Jan 2004 12:43
49 lines
2582 bytes
I dont understand this situation ... i'm using fwrite to write one struct to
file and after that to write array of classes ...
Wierd thing is when i read it from file just after writing to it, everything
works well but after restarting application i can read only struct
information and on class loading i receive access violation ...

struct sGroupInfo {
    short sNameLength;
    char strGroupName [25];
    short iNumberOfItems;
    };

class TTBarButton : public TCurrentBar
{
private:
    int FButtonID;
    Graphics::TBitmap *FIconGlyph;
    TIcon *FIcon;
    String FHint;
    String FAppPath;
    int FIconIndex;
    void SetIconGlyph (Graphics::TBitmap *Value);
    void SetAppPath (String AppName);
public:
    TPoint GridPosition;
    TTBarButton operator= (TTBarButton tb);
    __fastcall TTBarButton();
    __fastcall ~TTBarButton();
    __property Graphics::TBitmap *IconGlyph = {read=FIconGlyph,
write=SetIconGlyph};
    __property TIcon *Icon = {read=FIcon, write=FIcon};
    __property int ButtonID = {read=FButtonID, write=FButtonID};
    __property int IconIndex = {read=FIconIndex, write=FIconIndex};
    __property String Hint = {read=FHint, write=FHint};
    __property String AppPath = {read=FAppPath, write=SetAppPath};
};

    sGroup.sNameLength = strGroupName.Length ();
    strcpy (sGroup.strGroupName, strGroupName.c_str ());
    fwrite(&sGroup, sizeof (sGroup)+1, 1, stream); // write group name
length

    for (int i = 0; i < frmTBar->CBZ_Toolbar->CurrentBar->Count; i++) {
        fwrite(&frmTBar->CBZ_Toolbar->CurrentBar->cBZButtons[i],
sizeof(frmTBar->CBZ_Toolbar->CurrentBar->cBZButtons[i])+1, 1, stream); //
write struct s to file
        }

thanx
Technical Details
Message-ID: <400a7f9e@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,feb805d47c7e2f2b,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-01-18 05:09:24 PST
From: "ScOe" <cbinders@hotmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: how does fwrite i fread works ?
Date: Sun, 18 Jan 2004 13:43:10 +0100
Lines: 51
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 193.198.138.53
Message-ID: <400a7f9e@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1074429854 193.198.138.53 (18 Jan 2004 04:44:14 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail