🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

char *buf is bugged ?

#4985
From: Alfred
Date: Mon, 24 Oct 2005 12:49
16 lines
1580 bytes
Hello, I have a problem. I am writing a routing to read a file and write it into a Memo. I am using char *buf as buffer to read It becouse I need to change some parts before print it. The file I read is just a simple : "1" with no "" , so only 1 char. The output is : "1��" with no "".. what is wrong ? I have problems with only some File->Size and it work perfect with others File-Size.... I dont understand why...

void __fastcall TForm1::Button1Click(TObject *Sender)
{
        TFileStream *File=new
        TFileStream("list.txt",fmOpenRead);
        int Size=File->Size;
        char *buf = (char *) calloc( Size, sizeof(char) );
        File->Read(buf,Size);
        Form1->Memo->Lines->Add(buf);
        File->Free();
        free( buf );
}
Thank you
Alfred
Technical Details
Message-ID: <435cd85e$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!newscore.univie.ac.at!newsfeed.inode.at!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,a803499fd1f61208,start
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII
From: "Alfred" <alf@no.spam>
Sender: "Alfred" <alf@no.spam>
Reply-To: "Alfred" <alf@no.spam>
Subject: char *buf is bugged ?
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 82.52.161.215     
NNTP-Posting-Host: 207.105.83.66
Message-ID: <435cd85e$1@newsgroups.borland.com>
Date: 24 Oct 2005 05:49:34 -0700
X-Trace: newsgroups.borland.com 1130158174 207.105.83.66 (24 Oct 2005 05:49:34 -0700)
Lines: 16
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsgate.cistron.nl!newscore.univie.ac.at!newsfeed.inode.at!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail