From: "Cephaler" Newsgroups: comp.os.msdos.djgpp Subject: yet more questions about pointers Date: 15 Aug 1998 01:05:45 GMT Organization: ICGNetcom Lines: 35 Message-ID: <01bdc7e8$c1ff0e20$4ac3b8cd@scully> NNTP-Posting-Host: wbg-va2-10.ix.netcom.com Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Ok just concluded several tests concerning pointers, now I have some questions to verify my results: 1) A simple test program: int main(void) { char *string1=(char *)malloc(80); char *string2; strcpy(string1,"foobar"); string2 = string1; strcpy(string2,"raboof"); printf("%s\n",string1); return(0); } This yielded 'raboof' to my delight... Now, have I found a good use for pointers? Or is this bad bad code? 2) Having not initialized string2, a) do I have to free string2 and b) does that have any effect on string1? (oops didn't free string1) 3) concerning strcpy...is there any special reason why I shouldn't just use string1 = "foobar" ? If the answers to these questions are what I think they are my pointer dilemmas are over... (game still crashes though :( ) - Cephaler - p.s. thanks! <-- insert in previous messages as well