I am using C.
I have a fuction that returns a string
Code:
std::string name = getstingValue();
I need to format this string so that I can create a text file like so:
So I'm trying:
Code:
std::string newfilepath;
sprintf(newfilepath, "//myfolder//myfiles//%s", filename);
std::ofstream myfile(newfilepath.c_str());
But I get errors like:
cannot convert ‘std::string’ to ‘char*’ for argument ‘1’ to ‘int sprintf(char*, const char*, ...)’
How can I deal with this?