I can think of a couple of ways. Make sure there is enough room allocated
for the final resulting string plus one for the null terminator character
('/0').

void FirstWay (void)
{
   Char resultStr[10]; //make it big enough to hold the final string
   Char firstStr[5];

   //put a value into a string
   StrCopy (firstStr, "10");

   //format a string to contain the value above plus another string.
   // StrPrintf can contain different "%whatevers" for different values,
   // see the documentation under the StringManager for details.
   StrPrintf (resultStr, "%s days", firstStr);

   return;
}

void SecondWay (void)
{
   Char resultStr[10]; //make it big enough to hold the final string
   Char firstStr[5];
   CharPtr secondStr[] = " days";

   //put a value into a string
   StrCopy (firstStr, "10");

   //copy the value into the result string
   StrCopy (resultStr, firstStr);

   //concatenate the second string onto the result string
   StrCat (resultStr, secondStr);

   return;
}

> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of
> [EMAIL PROTECTED]
> Sent: Saturday, September 23, 2000 7:18 PM
> To: Palm Developer Forum
> Subject: another C question
>
>
> Most of you out there will think this is a dumb question, but it's
> confusing......If I have a variable of type char, and I want to
> set it with a
> variable and a string (i.e.-i want it to be equal to another char
> and append
> a string to it, like a variable number of days and the string " days"). I
> hope this even makes any sense, because im totally stumped.
>
> ( }#^} Ritz
>
> --
> For information on using the Palm Developer Forums, or to
> unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
>


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to