FidoNet Echomail Archive
aust_c_here

<<< Previous Index Next >>>

From: Adam Fitzpatrick
To: Joshua Marshall
Date: 1997-01-18 09:48:06
Subject: sprintf function

Quoting Joshua Marshall to Paul Edwards:



[snip]



JM>I ended up simply using another variable.  I thought it was an

JM>interesting point since I regularly used sprintf(s,

JM>"%s%s%d",s,"blah",8); code to append strings
rather than strcat(), and

JM>wrongly thought it might work...



JFYI, if you want to use sprintf to do what
sprintf(s,"%s%s%d",s,"blah",8)

would do if it worked, try
sprintf(s+strlen(s),"%s%d","blah",8). s+strlen(s)

points to the NUL character that terminates the string s, so the string it

creates from %s%d, blah and 8 will be written immediately after the last

character in the string s. When you're doing something other than appending

to the end though, like in your original question, using another variable

temporarily is generally the answer.





... If everything is coming your way, you're in the wrong lane!

--- FMail/Win32 1.22
 * Origin: Power BBS - +61-2-858-4114 - Files/Games/EchoMail/Internet (3:711/953)
SEEN-BY: 50/99 54/99 620/243 623/630 640/820 711/410 413 430 808 809 932 934
SEEN-BY: 711/946 953 963 712/311 407 505 506 517 623 624 704 841 713/317
SEEN-BY: 800/1
@PATH: 711/953 410 808 712/624 711/934


<<< Previous Index Next >>>