c++ - 使用 C++ 创建 HTML 报告

标签 c++ html visual-studio-2010

好吧,我已经完成编码并且所有结果都已准备就绪,我现在需要做的就是创建 HTML 报告来显示这些结果。如何使用 C++ 创建 HTML 报告?任何想法? 如果有帮助,我正在使用 Visual Studio 来编译和运行我的代码,尽管我不太热衷于使用 VS 库,而且我更喜欢使用 C++ std 库(如果有的话)。提前谢谢你

最佳答案

一种快速的方法是将 html 标签简单地写成字符串。 这是一个例子

    ofstream myfile;
    myfile.open ("C:\\report.html");
    myfile << "<!DOCTYPE html><html><head></head><body>"; //starting html

    //add some html content
    //as an example: if you have array of objects featuring the properties name & value, you can print out a new line for each property pairs like this:
    for (int i=0; i< reportData.length(); i++)
        myfile << "<p><span style='font-weight: bold'>" << reportData[i].name << "</span><span>" << reportData[i].value << "</span></p>";

   //ending html
    myfile << "</body></html>";
    myfile.close();

编辑:更新代码

关于c++ - 使用 C++ 创建 HTML 报告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11206604/

相关文章:

c++ - Qt控制台: Log all stdin and stdout to file

c++ - 为什么它打破了初始化列表的顺序规则时会起作用

html - Bootstrap 折叠切换不加载

html - 悬停时更改文本问题

C# 3des 加密,如何知道它何时失败?

c++ - 什么是样本格式?

c++ - %s 不能使用字符串

php - 我是否需要保护未连接到数据库的表单

c# - 如果发生错误,则中止网络测试

visual-studio - Visual Studio 2010 有 64 位版本吗?