🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3566

Re: crashes on char[]

#3566
From: John Gordon217-352-6511x7418CEER...
Date: Thu, 17 Jan 2002 22:00
35 lines
1942 bytes
"cal" <ccheng@cybermation.com> writes:

> Hi there,

> char asc[36864];
> struct tm* localTime = new tm();
> time(&timer);
> localtime_r(&timer,localTime);
> asctime_r(localTime, asc);
> time_date = strdup(asc);
> time_date[strlen(time_date) - 1] = '\0';

> or

> byte data[16384];
> for(long offs = element.offset; offs < length; )
> {
>   int cbRead = read(fileRead, data, 16384);
>    if(cbRead <= 0)
>    {
>     break;
>    }
>    offs = offs + cbRead;
>    write(fileWrite, data, cbRead);
>   }

you haven't given us enough information.  these code fragments *seem*
okay, but the problem could easily lie somewhere else in your program.
memory errors are very tricky.

you need to post the *entire* program.

---
John Gordon                  "No Silicon Heaven?  Preposterous!  Where would
gordon@osiris.cso.uiuc.edu    all the calculators go?" -- Kryten, Red Dwarf
Technical Details
Message-ID: <bQH18.7566$tg4.95062@vixen.cso.uiuc.edu>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!vixen.cso.uiuc.edu!gordon
References: <mqG18.95347$Z2.1353132@nnrp1.uunet.ca> <xKG18.7544$tg4.94829@vixen.cso.uiuc.edu> <QeH18.95370$Z2.1353672@nnrp1.uunet.ca>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,577607e3d4dd254d
X-Google-Attributes: gid11318c,public
X-Google-Thread: fc89c,577607e3d4dd254d
X-Google-Attributes: gidfc89c,public
X-Google-ArrivalTime: 2002-01-17 14:02:46 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.uchicago.edu!vixen.cso.uiuc.edu!gordon
Newsgroups: comp.unix.programmer,gnu.gcc.help
Subject: Re: crashes on char[]
References: <mqG18.95347$Z2.1353132@nnrp1.uunet.ca> <xKG18.7544$tg4.94829@vixen.cso.uiuc.edu> <QeH18.95370$Z2.1353672@nnrp1.uunet.ca>
From: John Gordon,217-352-6511x7418,CEERD-CF-N <gordon@osiris.cso.uiuc.edu>
User-Agent: nn/6.6.2
Lines: 35
Message-ID: <bQH18.7566$tg4.95062@vixen.cso.uiuc.edu>
Date: Thu, 17 Jan 2002 22:00:39 GMT
NNTP-Posting-Host: 128.174.5.51
X-Complaints-To: abuse@uiuc.edu
X-Trace: vixen.cso.uiuc.edu 1011304839 128.174.5.51 (Thu, 17 Jan 2002 16:00:39 CST)
NNTP-Posting-Date: Thu, 17 Jan 2002 16:00:39 CST
Organization: University of Illinois at Urbana-Champaign