String manipulation question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • krreks
    New Member
    • Oct 2008
    • 22

    String manipulation question

    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:

    Code:
    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
  • arnaudk
    Contributor
    • Sep 2007
    • 425

    #2
    You're not looking for sprintf(), are you?

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      To augment on the previous reply: sprintf() to the end of the buffer:

      Code:
      sprintf(ret+strlen(ret), "your format string here", a, b, c, d);
      kind regards,

      Jos

      Comment

      • krreks
        New Member
        • Oct 2008
        • 22

        #4
        Hi.

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

        Thanks anyway!

        Comment

        Working...