#include <iostream>
#include <fstream>
using namespace std;
int main()
{
string name;
cout<<"What would you like new html file to be named?"<<endl;
getline(cin,name);
cout<<"Creating New Html File...Moment."<<endl;
ofstream myfile (name);
if(myfile.is_open())
{
}
}
我需要制作一个带有 .html 扩展名的文件,谁能告诉我怎么做或者给我写个代码?
最佳答案
string name;
cout<<"What would you like new html file to be named?"<<endl;
getline(cin,name);
cout<<"Creating New Html File...Moment."<<endl;
name+=".html"; // the crucial ommision?
ofstream myfile (name);
关于c++ - 如何制作文件名和设置扩展名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/923768/