stau said:
Concatenating a string with an int with strcat is painful.
Please quote some context so we know what you are talking about.
sprinf(string, "%*c%d", strlen(string), string, num);
should do it, right?
No way to know, without knowing something about what sprinf is.
If you meant sprintf, then no. string still points to something that is
not modifiable. Even if it where, there's not enough space for the
resulting string. If those were fixed, this would still be broken. At a
purely syntactic level, you have supplied incorrect types for the first
2 arguments. The '*' tells it to expect an int, but you provide a
size_t. %c expects an int, but you provide a char *.
As for the logic, it's completely wrong. %c prints a single character,
not a string. The width specifier just adds spaces.
It's not clear whether strlen(string) would be useful or well-defined
when 'string' is the destination buffer (depends on whether it contains
anything useful initially).
I doubt sprintf() is well-defined when the destination buffer is also
used as a source.
-Kevin