Article View: borland.public.cppbuilder.nativeapi
Article #11688Re: how does fwrite i fread works ?
From: JD
Date: Sun, 18 Jan 2004 12:13
Date: Sun, 18 Jan 2004 12:13
23 lines
1757 bytes
1757 bytes
"ScOe" <cbinders@hotmail.com> wrote: > [...] 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 ... > fwrite(&frmTBar->CBZ_Toolbar->CurrentBar->cBZButtons[i], > sizeof(frmTBar->CBZ_Toolbar->CurrentBar->cBZButtons[i])+1, 1, stream); The problem is using AnsiString. The structure (and class) doesn't actually contain the string (text) but rather a pointer to the string so .... When you write it to the file, you are writing the address of a specific memory location - not any litteral text. That's why it works if you read it back right after you write it - the address is still valid within the context of the currently running application. It looks like what you're trying to accomplish is dfm-streaming. ~ JD
Technical Details
Message-ID:
<400a8667$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<400a7f9e@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,feb805d47c7e2f2b X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-01-18 05:25:01 PST From: "JD" <nospam@nospam.com> Sender: "JD" <nospam@nospam.com> Reply-To: "JD" <nospam@nospam.com> Subject: Re: how does fwrite i fread works ? Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 172.152.1.52 References: <400a7f9e@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <400a8667$1@newsgroups.borland.com> Date: 18 Jan 2004 05:13:11 -0700 X-Trace: newsgroups.borland.com 1074431591 207.105.83.66 (18 Jan 2004 05:13:11 -0700) Lines: 24 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail