Brett; Simon,
I originally wrote a C++ program to do what I want. Now I am trying to do it
in ROOT. I thought that most of C++ was compatible with ROOT, but
string::substr seems to be an exception.
Here are some lines from my ROOT macro.
const int commentstart=67;
const int commentlength=180;
string inputstring;
string comments;
(stuff)
inputstring=/*(line from a file)*/
//Takes the comments section as a substring
comments=inputstring.substr(commentstart, commentlength);
When I run this ROOT actually dies. It does not spit an error. It does not
give back a ROOT prompt. All I get back is my tsch prompt.
Sincerely,
Shawn Kwang
On Monday 22 July 2002 20:30, Brett Viren wrote:
> STL's string has
>
> string string::substr(begin_index, end_index).
>
> The indices count from 0.
>
> -Brett.
>
> Simon Dean writes:
> > Hi Shawn,
> >
> > You could try doing
> >
> > char mystring[200] = <the_name_of_your_TString_here>->Data();
> >
> > and then you could access whichever part of the string you wanted by
> > using the index; mystring[67] or whatever. Obviously, 'mystring' needs
> > to be big enough to accomodate your TString.
> >
> > Hope that helps,
> >
> > cheers,
> >
> > Simon
> >
> > On Mon, 22 Jul 2002, Shawn Kwang wrote:
> > > Roottalk,
> > >
> > > I want to extract a portion of a string (TString class). All I
> > > know is that the first character of the portion to be extracted starts
> > > at position 67. The portion is not constant so I can't use
> > > TString::Substring (since it looks for a pattern).
> > >
> > > I thought there might be a ROOT function that does what I want,
> > > TString:Strip but I am not sure.
> > >
> > > TIA,
> > > Shawn Kwang
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:00 MET