Re: My brains have gone dry and flakey - I can't get this to work!
From: Chris \( Val \) (chrisval_at_bigpond.com.au)
Date: 12/07/04
- Next message: Chris \( Val \): "[ OT ] Re: My brains have gone dry and flakey - I can't get this to work!"
- Previous message: Chris \( Val \): "Re: Namespace Qualification [was Re: Linux compiling]"
- In reply to: Paul F. Johnson: "My brains have gone dry and flakey - I can't get this to work!"
- Next in thread: Chris \( Val \): "[ OT ] Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Chris \( Val \): "[ OT ] Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Paul F. Johnson: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Anthony Borla: "STL Usage [Re: My brains have gone dry and flakey ...]"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 7 Dec 2004 17:56:16 +1100
"Paul F. Johnson" <paul@all-the-johnsons.co.uk> wrote in message
news:cp1pv6$25j1$1@mimas.salford.ac.uk...
| Hi,
|
| Probably the simplest thing in the world, but for some reason, I can't
| get it to work. It's basically a search and replace.
|
| Take a string, whizz through it and for each occurence of a letter,
| replace it with the capital.
|
| What I have is this (it's a small test)
[snip]
| int main()
| {
| string test = "d-mmmm-y", dummy;
| for (int t = 0; t < test.length(); ++t)
| {
| if (test[t] == 'm')
| dummy.insert(t, "M", 0, 1)
| else
| dummy[t] = test[t];
| }
| cout << test << " : " << dummy << endl;
| }
[snip]
You have quite a few corrections pointed out to you
about your code already, so I won't repeat them, but
I have to ask the question, what's wrong with using
the standard library features for this task ?:
# include <algorithm>
std::replace( test.begin(), test.end(), 'm', 'M' );
Cheers.
Chris Val
- Next message: Chris \( Val \): "[ OT ] Re: My brains have gone dry and flakey - I can't get this to work!"
- Previous message: Chris \( Val \): "Re: Namespace Qualification [was Re: Linux compiling]"
- In reply to: Paul F. Johnson: "My brains have gone dry and flakey - I can't get this to work!"
- Next in thread: Chris \( Val \): "[ OT ] Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Chris \( Val \): "[ OT ] Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Paul F. Johnson: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Anthony Borla: "STL Usage [Re: My brains have gone dry and flakey ...]"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|