Re: How to Split and join string ??
From: Chris \( Val \) (chrisval_at_bigpond.com.au)
Date: 01/29/05
- Next message: Chris \( Val \): "Re: Trying to underatand try throw and catch."
- Previous message: Ulrich Eckhardt: "Re: How to use XSendEvent(...)? (idesk mod)"
- In reply to: Ulrich Eckhardt: "Re: How to Split and join string ??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 29 Jan 2005 21:20:12 +1100
"Ulrich Eckhardt" <doomster@knuut.de> wrote in message
news:3613dtF4k50g7U1@individual.net...
| Anthony Borla wrote:
| > If you wish to actually *learn* to use C++ I'd recommend that you write
| > such [VB-like string manip] routines yourself. You already know the
| > interface you want - I assume identical [or at least as similar as
| > possible] to the corresponding VB functions - so all you need to do is
| > use the relevant C++ facilities to implement them. I guarantee you'll
| > learn much about the C++ language by tackling this project.
|
| Right, and then throw it all away and learn the interface of provided
| string types.
Throw what away ?, and why ?
| > One approach is to use the functionailty prototyped in the <cstring>
| > header which includes the functions std::strtok, std::strcpy, and
| > std::strcat.
|
| How can you recommend to a newbie to use those, most of all strtok which is
| broken by design? That, and the use of free storage allocated via
| new/malloc including all its pitfalls?
He didn't recommend these in preference to any others.
They were merely one of the options presented (that's
how I read it). The only recommendation I see is to write
ones own version to learn.
| Anthony, I believe that YOU could do this, but there is already enough bad
| C++ code out there, and your advise won't help a beginner write reasonable
| code.
To be honest, I thought Anthony' post was quite complete
and accurate, which presented all the facts and options
available.
I especially agree with Anthony' recommendation:
"If you wish to actually *learn* to use
C++ I'd recommend that you write such
routines yourself."
...and
"* Implement the routines using all three approaches"
..., and believe this is the best way for anyone to learn.
What do you expect a student to do when he gets his first
job, and comes across 'std::strtok()' ?, Run away and hide ?
How do you expect him to maintain older code ?, and lets
not forget, there is probably *much* more 'C' code out there
than 'C++'.
What kind of programmers do you think this train of thought
would bring us ?
The OP/Student *should* learn many approaches, and only then
can s/he make an informed decision about the advantages and
disadvantages of using each available option.
| > Another approach is to use STL library functionality with std::string,
| > and std::vector or std::list being obvious candidates for use, together
| > with the relevant iterator(s) or algorithm(s).
| >
| > Yet another approach is to use boost library functionality:
| >
| > http://www.boost.org/libs/libraries.htm
| >
| > Look for the 'tokenizer' link.
|
| Now this sounds much more sane.
It's just another option that was provided, but why do
you think that this is so sane ?
Imo, I would put this at the end of my list of things
to teach. As it stands, it just about takes an eternity
to learn the Standard Library effectively, given how vast
it is, let alone worrying about third party libraries.
Don't get me wrong, because I am a great believer in the
"C++ Standard Library", but I also recognise that to become
an *effective* programmer, you *need* to understand lower
level constructs as well, and the old 'C' functions are no
exception.
Cheers.
Chris Val
- Next message: Chris \( Val \): "Re: Trying to underatand try throw and catch."
- Previous message: Ulrich Eckhardt: "Re: How to use XSendEvent(...)? (idesk mod)"
- In reply to: Ulrich Eckhardt: "Re: How to Split and join string ??"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|