🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3834

Re: initialising arrays

#3834
From: Bob Weaver
Date: Wed, 23 Aug 1995 21:04
17 lines
1065 bytes
Gary Barter <gbarter@tsdesign.zynet.co.uk> wrote:
>
> I'm using Borland C++ 4.02 and I am looking for a way to make the 
> compiler leave an array uninitialised. At present it sets all global 
> arrays to zero. This is a problem as I'm using arrays of 2-4 Mbs in size 
> which have to be initialized with data when the program is run.
> Is there a way to turn off this auto - initialisation ??

 
The standard sez: Globals and static locals get initialized to zero.
Since you want the array to be global (not wonderful--do ya gotta?),
just declare a pointer to the type instead and malloc() the space
you need using the pointer (calloc() initializes, malloc()doesn't).  


Hope this helps.
Bob Weaver
Technical Details
Message-ID: <41g553$711@ruby.ucc.nau.edu>
Path: arc1-ca.pugleaf.net!ruby.ucc.nau.edu!news
References: <41ccgu$536@sol.zynet.net>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!ruby.ucc.nau.edu!news
From: Bob Weaver <rpw@alpine.for.nau.edu>
Newsgroups: comp.std.c
Subject: Re: initialising arrays
Date: 23 Aug 1995 21:04:35 GMT
Organization: Northern Arizona University, Flagstaff AZ, USA
Message-ID: <41g553$711@ruby.ucc.nau.edu>
References: <41ccgu$536@sol.zynet.net>
NNTP-Posting-Host: pc001.for.nau.edu