0 c++
#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())
{
}
}
Run Code Online (Sandbox Code Playgroud)
我需要使用.html扩展名制作myfile,有人可以告诉我如何编写代码吗?
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);
Run Code Online (Sandbox Code Playgroud)