I have a bunch of variable strings and was wondering if there was a quicker/easier way of sticking them all together into one big string other than with strcat(a, strcat(b, strcat(c,d))))
I have a bunch of variable strings and was wondering if there was a quicker/easier way of sticking them all together into one big string other than with strcat(a, strcat(b, strcat(c,d))))
snprintf() is good:
If you don't have snprintf(), you can use sprintf(); but be careful, because you can't tell sprintf() the size of your buffer. You also have to write into a new location; you can't "reuse" one of the strings, as in:Code:char str[1024]; snprintf(str, sizeof str, "%s%s%s%s", a, b, c, d);
Because this tries to write "a" into "a", it's not valid.Code:snprintf(a, sizeof a, "%s%s%s%s", a, b, c, d);
Cheers, that was just what I needed