"mlimber" <mlimber@gmail.com> wrote in message news:1128965904.835293.14400@g14g2000cwa.googlegro ups.com...[color=blue]
>
> Alex Vinokur wrote:[color=green]
> > I have got two functions:
> >
> > void foo1(char* str)
> > {
> > // Stuff
> > }
> >
> > void foo2(int size)
> > {
> > char* str;
> > str = new char[size];
> > // Stuff-1
> > foo1(str)
> > // Stuff-2
> > }
> >
> > Function foo1() can't be changed.
> > Function foo2() can be changed.
> >
> > I would like to use string::c_str() instead of char* in new version of foo2();
> > Something like:
> >
> > void new_foo2(int size)
> > {
> > string str(size, '0');
> >
> > // Stuff-1
> > foo1(str.c_str())
> > // Stuff-2
> > }
> >
> > It seems to be problematic.
> >
> > Is there any appropriate solution?[/color]
>
> In what way is it problematic? Compiler errors? Run-time errors? Speed
> change? Please elaborate.
>
> Cheers! --M
>[/color]
I think it is unsafe.
--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html http://sourceforge.net/users/alexvn