From: Damian Yerrick Newsgroups: comp.os.msdos.djgpp Subject: Re: Pointers and Arrays (Newbie.) Organization: Pin Eight Software http://pineight.8m.com/ Message-ID: References: <39533dab$1 AT news DOT telinco DOT net> X-Newsreader: Forte Agent 1.7/32.534 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 33 X-Trace: /bV2/6BTRHR/vRO1GVkaDSDklmGskB6hZk4YA+ENwRDmgczxzBJ2EJD73geb82DAoeeQKvziNMB1!Z2CP8ngH01fhbpTJ8nEImKI1wb/zl5/9sXNfMKbdBHh+7ubg2paSVebecggmtx/23hkOHF6M8P0r!mdx5 X-Complaints-To: abuse AT gte DOT net X-Abuse-Info: Please be sure to forward a copy of ALL headers X-Abuse-Info: Otherwise we will be unable to process your complaint properly NNTP-Posting-Date: Sat, 24 Jun 2000 07:39:47 GMT Distribution: world Date: Sat, 24 Jun 2000 07:39:47 GMT To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com On Fri, 23 Jun 2000 11:29:15 +0100, "Adrian Smith" wrote: >My program has a header file in which I've got :- > >const char * message = "This is an error message \n" > >In the main .cpp file I've got :- > >cout << message << endl; > >When i try to compile, it comes up with:- > >error : : multiple defenition of 'message' > >If i use an array - ie, const char message[30] = "This is an error message >\n" >this works perfectly. Could somebody please tell me where Iam going wrong >with the pointer method. You're trying to store a string inside a pointer. This is just wrong. Strings are supposed to go into character arrays. If you want an array that is just big enough to hold what you put into it, do this: const char message[] = "hello world\n"; -- Damian Yerrick "I refuse to listen to those who refuse to listen to reason." See the whole sig: http://www.rose-hulman.edu/~yerricde/sig.html This is McAfee VirusScan. Add these two lines to your signature to prevent the spread of signature viruses. http://www.mcafee.com/