delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/13/18:23:33

From: "Campbell, Rolf [SKY:1U32:EXCH]" <cp1v45 AT americasm01 DOT nt DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Catenation (spelled right?) of strings
Date: Fri, 13 Aug 1999 14:45:36 -0400
Organization: Nortel Networks
Lines: 26
Message-ID: <37B467D0.B2496F3E@americasm01.nt.com>
References: <37B36D0D DOT 7F00 AT lords DOT com> <37B37890 DOT 2C249FED AT a DOT crl DOT com> <37B4490F DOT 1EB AT lords DOT com>
NNTP-Posting-Host: bmerhc00.ca.nortel.com
Mime-Version: 1.0
X-Mailer: Mozilla 4.7 [en] (X11; I; HP-UX B.10.20 9000/712)
X-Accept-Language: en
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

"Robinson S." wrote:

> > The correct thing to do is:
> >   char *theString = "Goats " "make " "good " "pets!";
>
> Great, that seems to work. But, it brings up some other questions:
> What if I want to add variables and strings to the char:
> ---
> char * ANIMAL = "Goats";
> char *theString = ANIMAL "make " "good " "pets!";
> ---
> How would that be accomplished?

    That way is only for literal strings.  If you want to add variables,
then you will have to use strcat.

> Also, can i modify *theString after having declared it as above, or has
> it become a constant?

    You can modify theString, but not *theString.

--
     -Rolf Campbell (39)3-6318



- Raw text -


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