From: "Cabra" Newsgroups: comp.os.msdos.djgpp Subject: Re: yet more questions about pointers Date: Tue, 8 Sep 1998 16:32:12 +0200 Organization: Que me quiten LOBAILAO Lines: 30 Message-ID: <6t7bg7$pih$1@diana.bcn.ibernet.es> References: <01bdc7e8$c1ff0e20$4ac3b8cd AT scully> <35D5B41F DOT 4534F8E4 AT unb DOT ca> <35e754f4 DOT 2457929 AT cnews DOT newsguy DOT com> NNTP-Posting-Host: 194.75.70.157 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk wpp AT brinet DOT com escribió en mensaje <35e754f4 DOT 2457929 AT cnews DOT newsguy DOT com>... >On Sat, 15 Aug 1998 13:15:28 -0300, Endlisnis wrote: > >>Cephaler wrote: >> >>> int main(void) { >>> char *string1=(char *)malloc(80); >>> char *string2; >>> strcpy(string1,"foobar"); >>> string2 = string1; >>> strcpy(string2,"raboof"); >>> printf("%s\n",string1); >>> return(0); >>> } [...] >>> 3) concerning strcpy...is there any special reason why I shouldn't just use >>> string1 = "foobar" ? >> >> Not to my knowledge (except you can't 'free' that space). In 'Cygnus' GCC, this definition is considered a 'non-const' pointer to a 'const' bunch of bytes, i.e. you can point to it, but you can't modify this contents. You can define 'char string1[]="foobar"' to avoid this behaviour. DJGPP (with the aproppiate compiler options) warn this, but IIRC, 'Cygnus' not.