I used snprintf(), too, but it is only a minor improvement. Problematic in C is something as simple as concatenating strings:
Mystring s,t;
t = "hello";
t = cat(s,s);
t = cat(s,s,s);
t = cat("hello",s);
t = cat(s,"world");
t = cat("hello","world");
Even such a simple use case is fraught with major problems:
1. who allocates needed memory?
2. who free's it?
3. can the compiler constant fold cat("hello","world") ? Does the result wind up allocating memory anyway?
4. what about the lack of function overloading to handle the permutations?
1. who allocates needed memory?
2. who free's it?
3. can the compiler constant fold cat("hello","world") ? Does the result wind up allocating memory anyway?
4. what about the lack of function overloading to handle the permutations?