possible bug in string::substr and usablity question
Jonathan Hudson
nathanoj@fastmail.fm
Tue Feb 10 03:44:00 GMT 2004
string::substr does not always return
the right substring.
I used the program:
----------------------------------
#include <iostream>
#include <string>
#include <list>
using namespace std;
int main()
{
string line("testing \"hello\"");
cout << " read \"" << line.substr(0,7) << "\"" << endl;
cout << " quote read \"" << line.substr(9,11) << "\"" << endl;
cout << " constructor \"" << string(line.c_str(), 9, 11) << endl;
cout << " for loop: ";
for(int i=9; i<11; i++)
cout << line.at(i);
cout << endl;
return 0;
}
-----------------------------------
and I get
-----------------------------------
read "testing"
quote read "hello""
constructor "hello"
for loop: he
-----------------------------------
I found and checked out the checklist in my search
for this list. I'm writing an uc layout editor
based on magic. Now I'm wondering if this stl
is ready to be used in that project. Do you
think it's ready? Is it a good way to find
bugs in this stl?
-- Jonathan
--
http://www.fastmail.fm - One of many happy users:
http://www.fastmail.fm/docs/quotes.html
More information about the Libstdc++
mailing list