を使用char[]
して変更することができますsprintf
。そんな感じ:
ofstream outFile_raw;
ofstream outFile_txt;
std::string data;
std::string format_raw="raw";
std::string format_txt="txt";
char fileName[20];
sprintf(fileName, "..\\Packages\\packet_a.%s", format_raw);
outFile_raw.open(fileName, ios::trunc);
if(outFile_raw.is_open())
{
outFile_raw<< data; // Write contents of the data to the file stream.
outFile_raw.close();
}
sprintf(fileName, "..\\Packages\\packet_a.%s", format_txt);
outFile_txt.open(fileName, ios::trunc);
if(outFile_txt.is_open())
{
outFile_txt<< data; // Write contents of the data to the file stream.
outFile_txt.close();
}