Quote:Original post by Splinter of Chaos
I think I like godsenddeath's solution the best right now.
I don't. An extra buffer is unnecessary. Using char pointers in favour of real C++ string objects is a bad habit to get into. It only checks for space characters, which is not the same as isspace (which counts: single space, tab, vertical tab, form feed, carriage return, or newline).
Quote:
Yes, the problem can be solved in one line, but is the goal here to solve Celephix's problem, or teach him?
Both. He can use the simpler ones for reference, but in practise use the one liners.
Its like std::vector (or any container), sane people avoid looking at the implementation. When we are learning, we write our own version so we can understand what goes on inside the Standard Library Containers. When writing code, we do not use our hand-rolled version.