strcat(3) should generally be avoided, unless you know 100% everything will fit.
Instead, in this case it would be better to use snprintf(3), though you can still get string truncation, or if you have GNU extensions you can use asprintf(3), which is like sprintf(3) but dynamically allocates the buffer.
Using snprint(3), your block of strcat()'s and malloc() can be reduced to...
Quick tip.
strcat(3) should generally be avoided, unless you know 100% everything will fit.
Instead, in this case it would be better to use snprintf(3), though you can still get string truncation, or if you have GNU extensions you can use asprintf(3), which is like sprintf(3) but dynamically allocates the buffer.
Using snprint(3), your block of strcat()'s and malloc() can be reduced to...
Freaking brilliant! Worked like a charm, easier to read and configure. That's why I'm a noob.
Thanks,
Cool, no problem!
Thanks, I'll have to give that a try.