🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: hepnet.lang.c++
Article #7

Re: dynamicaly allocating a two dim. array

#7
From: Jarmo Paavilainen
Date: Tue, 31 Oct 1995 08:09
31 lines
1273 bytes
In message <46d9ak$c5h@ixnews7.ix.netcom.com> - techman2@ix.netcom.com (Peter 
Dennis ) writes:

:> float array[x][y];

First C++ version

float **array;

array = new float*[x];
for(i = 0;i < x;i++)
 { array[i] = new float[y]; }

and then C

float **array;

array = (float**)malloc(sizeof(float)*x);
for(i = 0;i < x;i++)
 { array[i] = (float*)malloc(sizeof(float)*y); }

Code not tested but it should work ( the C++ version anyway ).


Take care,
Skorpio

ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͻ
ºJarmo Paavilainen ( alias : Skorpio ) ³e-mail : skorpio@dataphone.se  º
ºSweden                                ³home   : ?                     º
ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
Technical Details
Message-ID: <474ljk$551@nic.dataphone.se>
Path: arc1-ca.pugleaf.net!news.dataphone.se!news
References: <DG7ExA.3CG@cunews.carleton.ca> <dqua.813429186@dqua>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.dataphone.se!news
From: skorpio@dataphone.se (Jarmo Paavilainen)
Newsgroups: hepnet.lang.c++,comp.lang.c,comp.lang.c++,cern.c++
Subject: Re: dynamicaly allocating a two dim. array
Date: 31 Oct 1995 08:09:24 GMT
Organization: Dataphone Public Internet Sweden +46-8-7043121
Message-ID: <474ljk$551@nic.dataphone.se>
References: <DG7ExA.3CG@cunews.carleton.ca> <dqua.813429186@dqua>
NNTP-Posting-Host: nikson.dataphone.se
X-Newsreader: NeoLogic News for OS/2 [version: 4.2]