thebarslider
Programmer
I'm trying to convert a ostringstream to a char*.
I have so far managed to convert ostringstream to string but get errors when trying to convert to char* using
c_str();
below is my code:
GetLocalTime(&now);
std:
stringstream strstrm;
strstrm << now.wDayOfWeek << "/" << now.wDay
<< "/" << now.wMonth
<< "/" << now.wYear << " " << now.wHour << ":"
<< now.wMinute << ":" << now.wSecond << ".mp3";
strstrm.str();
strstrm.c_str();
// Open/Create MP3 file to store output to
pFileOut = fopen( strstrm, "wb+" );
I recieve the following error on compilation:
C2039: 'c_str' : is not a member of 'std::basic_ostringstream<_Elem,_Traits,_Alloc>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Alloc=std::allocator<char>
]
And therefore i cannot pass to fopen.
Is it possible to create a file using a string for filename? Could i bypass this conversion somehow?
I have tried to place c_str(); in scope by using:
strstrm.basic_string::c_str();
but still my code doesnt work.
I hope someone can help.
Any help will be much appreciated.
Mark.
I have so far managed to convert ostringstream to string but get errors when trying to convert to char* using
c_str();
below is my code:
GetLocalTime(&now);
std:
strstrm << now.wDayOfWeek << "/" << now.wDay
<< "/" << now.wMonth
<< "/" << now.wYear << " " << now.wHour << ":"
<< now.wMinute << ":" << now.wSecond << ".mp3";
strstrm.str();
strstrm.c_str();
// Open/Create MP3 file to store output to
pFileOut = fopen( strstrm, "wb+" );
I recieve the following error on compilation:
C2039: 'c_str' : is not a member of 'std::basic_ostringstream<_Elem,_Traits,_Alloc>'
with
[
_Elem=char,
_Traits=std::char_traits<char>,
_Alloc=std::allocator<char>
]
And therefore i cannot pass to fopen.
Is it possible to create a file using a string for filename? Could i bypass this conversion somehow?
I have tried to place c_str(); in scope by using:
strstrm.basic_string::c_str();
but still my code doesnt work.
I hope someone can help.
Any help will be much appreciated.
Mark.