A
Alex Vinokur
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?
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?