You are using the same source and target string (in your example: 'str'
string pointer).
Solution: Define your own sprintf() or use
char str[100],dest[100];
StrCopy(str,"Hello");
StrPrintF(dest,"%s World",str);
/* => result in "Hello World" */
BTW: Anybody know if ANSI permit the same source/target ptrs in sprintf()?
Y.Rekha wrote:
Hello,
I am developing an application which utilizes a library. This library
makes a bunch of sprintf calls which needs to be mapped to device
specific API(Palm/Symbian).
I used StrPrintF on Palm as mentioned in the manual, but the intended
operation is not performed. I read in the developer forums that the
StrPrintF does not implement all the features of ANSI sprintf. I have a
piece of code which is like:-
Char str[100];
MemSet(str,100,0);
StrCopy(str,"Hello");
StrPrintF(str,"%s World",str);
At this point , all str has is " World", "Hello" is getting removed. I
tried this using other "C" compiler(on desktop) and it gives "Hello
World" as the output.
Is there a way we can use C's sprintf - considering newer releases of
CW?
Is there/should there be a work around for StrPrintF?
I am using Metrowerks CodeWarrior 9.3 Prof. edition.
Thanks in advance,
Rekha
--
* * * * * * * * * * * * * * * * * * * * * * * * * * * *
Ralf Dietrich www: http://www.envicon.com
envi.con KG mail:[EMAIL PROTECTED]
Emser Platz 2 Tel: +4930-34902670
10719 Berlin/Germany Fax: +4930-34902671
--
For information on using the Palm Developer Forums, or to unsubscribe, please
see http://www.palmos.com/dev/support/forums/