I have a problem with creating a file, whose name is a little bit modified from some other file's name.
But if the new name is not based on another name - the program works - but I need to use that first method.
I used backslash (\b) to remove ".srt" from the original file name to modify the copy - in this program, I cannot modify path_file_1 and path_file_2, so I cannot just miss the extension and add it later when I finished preparing the copy.
Here's the code:
#include <iostream>
#include <fstream>
int main()
{
std::cout << "Starrting!" << std::endl;
std::string path_file_1 = "Sub-File1.srt";
std::string path_file_2 = "Sub-File2.srt";
std::string path_file_new = path_file_1 + "\b\b\b\b-corr.srt";
//std::string path_file_new = "Sub-File1-corr.srt";
//this works!
std::cout << path_file_1 << std::endl;
std::cout << path_file_new << std::endl;
//Creating a new file
std::fstream file;
file.open(path_file_new, std::ios::out | std::ios::binary);
if (!file)
{
std::cout << "Error in creating file!!!";
return 0;
}
std::cout << "File created successfully." << std::endl;
file.close();
}
Here's the output:
Starrting!
Sub-File1.srt
Sub-File1-corr.srt
Error in creating file!!!