如何在ubuntu中的c++中设置html

How to setup html within c++ in ubuntu?

本文关键字:设置 html c++ 中的 ubuntu      更新时间:2023-10-16

我想用C++设计一个网页。在ubuntu PC中,从C++文件设计它所需要的所有软件包是什么?

我还想知道如何将c++文件的输出重定向到web浏览器。

我只想从C++文件输出一些HTML,不想写任何web服务器。

假设您指的是C++ executable,那么只需将其输出到一个文件(扩展名为.html)就可以实现这一点。

大致如下:

#include <iostream>
#include <fstream>
int main() {
    std::ofstream htmlfile;
    htmlfile.open ("index.html");
    htmlfile << "<!DOCTYPE html>";
    htmlfile << "<html>";
    htmlfile << "<head>";
    htmlfile << "<meta charset="UTF-8">";
    htmlfile << "<title>Title of the document</title>";
    htmlfile << "</head>";
    htmlfile << "<body>";
    htmlfile << "Content of the document.";
    htmlfile << "</body>";
    htmlfile << "</html>";
    htmlfile.close();
}