Hi Mike,
>
> Hi,
>
> Could someone explain the following behaviour to me?
>
> #include <strstream>
> #include <iostream>
> #include "TROOT.h"
> #include "TApplication.h"
>
> TROOT rsession("test", "test");
>
> main(int argc, char** argv)
> {
> // TApplication app("App", &argc, argv);
> ostrstream buf;
> buf<< "hello";
you should do
buf << "hello" << '\0';
to be safe. At least the GNU libg++ library says that
you should (from info iostream):
- Method: char* ostrstream::str ()
A pointer to the string managed by this `ostrstream'. Implies
`ostrstream::freeze()'.
Note that if you want the string to be nul-terminated, you must do
that yourself (perhaps by writing ends to the stream).
So it's gnu libg++ related, not CINT (I don't know whether
I posted the small example which tries to reuse the same
memory for two variables to demonstrate that the string
is only accidentally null-terminated if you don't write
a '\0' af the end).
best regards,
André
--
------------------+----------------------------------
Andre Holzner | +41 22 76 76750
Bureau 32 2-C13 | Building 32
CERN | Office 2-C13
CH-1211 Geneve 23 | http://wwweth.cern.ch/~holzner/
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:45 MET