My brains have gone dry and flakey - I can't get this to work!
From: Paul F. Johnson (paul_at_all-the-johnsons.co.uk)
Date: 12/06/04
- Next message: Karl Heinz Buchegger: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Previous message: Anthony Borla: "main() return type convention [was Re: Linux compiling]"
- Next in thread: Karl Heinz Buchegger: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Karl Heinz Buchegger: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Alwyn: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Karl Heinz Buchegger: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: jcoffin_at_taeus.com: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Chris \( Val \): "Re: My brains have gone dry and flakey - I can't get this to work!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 06 Dec 2004 14:22:29 +0000
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)
#include <iostream>
#include <string>
using namespace std;
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;
}
This will compile, but aborts with the error
terminate called after throwing an instance of std::out_of_range
what(): basic_string::insert
Aborted
Okay, I knew insert would be a problem, but the prefered method of
dummy[t] = "M"
gives an error of a conversion from const char * to char *.
As I say, my braincell is befuddled today - any help would be great.
TTFN
Paul
- Next message: Karl Heinz Buchegger: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Previous message: Anthony Borla: "main() return type convention [was Re: Linux compiling]"
- Next in thread: Karl Heinz Buchegger: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Karl Heinz Buchegger: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Alwyn: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Karl Heinz Buchegger: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: jcoffin_at_taeus.com: "Re: My brains have gone dry and flakey - I can't get this to work!"
- Reply: Chris \( Val \): "Re: My brains have gone dry and flakey - I can't get this to work!"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|