Alex Rivera | Logout

How to append strings using sprintf?

Asked 2010-04-20T10:36:55.583
104

I am facing a serious issue with sprintf.

Suppose my code snippet is:

sprintf(Buffer,"Hello World");
sprintf(Buffer,"Good Morning");
sprintf(Buffer,"Good Afternoon");
.
.
.

Some hundred sprints....

If I do like this, it's getting overwritten.

How can I avoid overwriting using sprintf? If I give a printf at the end I want to see all the lines.

Edit
Report

1 Answer

6

I find the following method works nicely.

sprintf(Buffer,"Hello World");
sprintf(&Buffer[strlen(Buffer)],"Good Morning");
sprintf(&Buffer[strlen(Buffer)],"Good Afternoon");
answered 2013-03-28T13:45:41.253

Your Answer