www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/07/26/16:45:14

From: Horst Kraemer <horst DOT kraemer AT gmx DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: How to convert mode to "pointer to array"?
Date: Wed, 26 Jul 2000 22:37:13 +0200
Lines: 25
Message-ID: <qriunssc4finh95f4o8vn9gp9siss3lvtg@4ax.com>
References: <39780BA1 DOT 7354F5D2 AT umist DOT ac DOT uk>
NNTP-Posting-Host: a1017.pppool.de (213.6.16.23)
Mime-Version: 1.0
X-Trace: fu-berlin.de 964643825 5225111 213.6.16.23 (16 [27606])
X-Newsreader: Forte Agent 1.8/32.548 trialware
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Fri, 21 Jul 2000 09:36:49 +0100, Anthony Appleyard
<Anthony DOT Appleyard AT umist DOT ac DOT uk> wrote:

> I wrote a Gnu C++ program with this text in;-
> 
> class atom{public: double x,y,z; char mat,vis; atom(){};
>     atom(xyz c,char m=0,char v=0){x=c.x; y=c.y; z=c.z; mat=m; vis=v;};
> 
> atom((*C)[N+1][N+1])= /*HERE*/ malloc((N+1)*(N+1)*(N+1)*sizeof(atom));
> 
> My Gnu C++ compiler accepts this, but moans that implicit conversion
> from void* to a pointer is non-ANSI, so I likely couldn't use that
> program text in my good old faithful Borland C++ 4.52 for Windows. To
> make this text ANSI, what should I insert at /*HERE*/ ?

Nothing. You should use 'new' instead of malloc.

	atom (*C)[N+1][N+1] = new atom [N+1][N+1][N+1];

supposing that N is a macro or a const known at compile time.


Regards
Horst

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019