delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/13/09:42:58

Date: Mon, 13 Oct 1997 15:40:23 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Guan Foo Wah <djgpp AT rocketmail DOT com>
cc: djgpp AT delorie DOT com
Subject: Re: Is this a bug ??? or feature ??
In-Reply-To: <19971013092045.160.rocketmail@send1.rocketmail.com>
Message-ID: <Pine.SUN.3.91.971013153657.11407d-100000@is>
MIME-Version: 1.0

On Mon, 13 Oct 1997, Guan Foo Wah wrote:

> This time, num[1], and id[2] share the same memory location.
> Can anyone please tell me how to make those three variables not to
> share
> the same memory location ?? This is important in my project which I am
> currently working on.

Somebody already posted the gcc switch to do that.  But I would like to
point out that what you are doing is non-portable.  Some compilers won't
let you write into constant strings at all, others would result in subtle
bugs.  The reason is that some compilers put constant strings into 
read-only data, where you cannot change anything at run time.

The right thing to do is to copy the strings into automatic arrays (with 
strcpy etc.) and then manipulate them as you see fit.

- Raw text -


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