First of all, in your declarations, you have only declared three *pointers*
to chars, not three strings.  No memory has been allocated for the strings
yet.  So you must either declare the strings as:

char    sdf[10], ghj[10], klm[10];

or must use alloc or malloc to allocate memory for the strings.

Secondly, you can't just set a string value by using "=" (except in the
declaration).  You must use something like strcpy to set the string:

char    sdf[10], ghj[10], klm[10];

strcpy (sdf, "ABC");
strcpy (ghj, "XYZ");

Finally, to put the strings together, there are a number of ways you could
do this.  One is just to concatenate them:

strcpy (klm, sdf);      // Copies contents of sdf ("ABC") to klm
strcat (klm, ghj);      // Appends contents of ghj ("XYZ") to klm, giving
"ABCZXY"

To do this with StrPrintF, you could do something like the following:

StrPrintF(klm, "%s%s", sdf, ghj);

The first parameter is the destination variable, the second is a format
string (%s represents a string, so %s%s represents two strings with nothing
between them), and the other variables are used to populate the format
string.  Since the format string is %s%s, the function is expecting two
strings to be found in the list of variables.  The value of sdf gets plugged
into the first %s and the value of ghj gets plugged into the second %s.

Hope this helps,

Mike Walters
Rose Software



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Pieterjan Vandegaer
Sent: Wednesday, January 01, 2003 12:38 PM
To: Palm Developer Forum
Subject: StrPrintF example needed


I'm trying to figure out some of the details of the StrPrintF function:

suppose:

char *sdf, *ghj, *klm;
sdf = "ABC";
ghj = "XYZ";

How could I put sdf en ghj into another variable klm (becoming klm ==
"ABCXYZ") using the StrPrintF function?  Or are there better ways of
managing 'strings'?

Thx in advance,
--PieterJ.



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


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

Reply via email to