> >=20
> > Here is the code, any idea what might be going wrong here??
> >=20
> > function call:
> > countOutp->value(GetCountString()); //output as c style string
> >=20
> > Implementation:
> >=20
> > const char* ListBuilder::GetCountString()
> > {
> > string outputStr; //temp output string
> > ostringstream countVal; //convert int value to string
> > countVal << count; //convert count integer to char string
> > outputStr =3D countVal.str(); //assign contents to string object
> >=20
> > return outputStr.c_str(); //return as c style string
> > }
>
> Your string goes out of scope as soon as the function returns (you have cre=
> ated it on the stack, local to the function) so anybody trying the read the=
> returned c_string later on will just get garbage... As you have noticed.
>
> If this is what you want to do, you need to declare string outputStr as sta=
> tic, so that it will persist after your function returns.
O my goodness, talk about not seeing the wood for the trees, what an
elementary error.. i can honestly say that was the one beginner mistake,
I never made 'returning variable that is about to go out of scope..'
Never made till today that is..o groan!
Thanks!
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk