3

I already made a CPP program about this that creates a lot of files with Dev C++, this one's with Dev C++ too but now it shows error. My code is specialized on creating HTML templates, but it shows error.

This is some of my code :

#include <iostream>
using std::cout;
using std::cin;
using std::ofstream;
using std::endl;

void HelloWorld() {
    ofstream outfile ("html1.html");

    outfile << "<html> " << endl;
    outfile << "   <head> <title> Template Hello World </title> </head>" << endl;
    outfile << "   <body> <h1> Hello World! </h1> </body> " << endl;
    outfile << "</html> " << endl;
    outfile << "// Template HTML 2018 " << endl;
    cout << "Created Succesfuly! Directory: Program's folder " << endl;


    outfile.close(); 
}

1 Answers1

4

Just add #include <fstream> to your includes :

#include <iostream>
#include <fstream>
using std::cout;
using std::cin;
using std::ofstream;
using std::endl;

void HelloWorld() {
    ofstream outfile ("html1.html");

    outfile << "<html> " << endl;
    outfile << "   <head> <title> Template Hello World </title> </head>" << endl;
    outfile << "   <body> <h1> Hello World! </h1> </body> " << endl;
    outfile << "</html> " << endl;
    outfile << "// Template HTML 2018 " << endl;
    cout << "Created Succesfuly! Directory: Program's folder " << endl;

    outfile.close();
}

int main()
{
    HelloWorld();
    return 0;
}

Output :

Created Successfully! Directory: Program's folder