Why is the pointer not pointing?

Pages: 12
When properly used, std::string has no more overhead than doing the allocations and concatenations by hand.
The most common situation of not using std::string properly is this:
s=s+list+of+strings;
instead of
1
2
3
4
s.reserve(s.size()+list.size()+of.size()+strings.size()); //optional
s.append(list);
s.append(of);
s.append(strings);


I think the problem here is that there's someone using C++ to teach programming. If this was Pascal, I'd agree that there's a point in teaching string concatenation by hand, but in C++ it just doesn't make sense. You're just adding more places where you can screw up, and, even worse, it has a chance of creating bad habits.

Anyway, just replace the std::string stuff with
1
2
char filename[100];
sprintf(filename"%s%d.txt",prefixes[a],weekNumber);
Topic archived. No new replies allowed.
Pages: 12