By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,951 Members | 1,365 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,951 IT Pros & Developers. It's quick & easy.

String manipulation question

P: 22
I need to concatenate a string with a dynamic part (don't know what the %d's and it's likes are called)... And exactly the fact that I don't know the name of what I'm trying to do is what makes so hard to google it :)

What I wan't to look something like this in my head:

Expand|Select|Wrap|Line Numbers
  1. strcat(ret, "! [%d] %s", i, buf);
The code above won't work, but what will? I don't wan't to do a dozen of strcats either...

I hope somebody will point it out :)

Thanks in advance
Nov 17 '08 #1
Share this Question
Share on Google+
3 Replies

P: 424
You're not looking for sprintf(), are you?
Nov 17 '08 #2

Expert 10K+
P: 11,448
To augment on the previous reply: sprintf() to the end of the buffer:

Expand|Select|Wrap|Line Numbers
  1. sprintf(ret+strlen(ret), "your format string here", a, b, c, d);
kind regards,

Nov 17 '08 #3

P: 22

The sprintf function was what I was looking for, I found it myself and the problem got solved :)

Thanks anyway!
Nov 17 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.