用HTML做一个简单的网站
代码如下(注意是c++)
#include <fstream>
#include <stdlib.h>
#include <string>
using namespace std;
int main(){
char code[10][100]={
"<!DOCTYPE html>",
"<html>",
"<head>",
//"<meta charset=\"utf-8\">",
"<title>我的HTML程序</title>",
"</head>",
"<h1>hello world</h1>",
"<p>hello world</p>",
"</body>",
"</html>",
};
ofstream outfile("hello world.html");
for (int i=0;i<10;i++){
outfile<<code[i]<<'\n';
}
outfile.close();
system("start hello world.html");
}
红框中的自可以自己改,内容太多需要把char后面改大一点
运行效果
没登录的小伙伴可以抄这里
#include <fstream>
#include <stdlib.h>
#include <string>
using namespace std;
int main(){
char code[10][100]={
"<!DOCTYPE html>",
"<html>",
"<head>",
//"<meta charset=\"utf-8\">",
"<title>我的HTML程序</title>",
"</head>",
"<h1>hello world</h1>",
"<p>hello world</p>",
"</body>",
"</html>
}
谢谢支持!