Website Generator using C++

Website Generator using C++ is one of the simple yet most useful C++ project. You can also use the basic idea given in this blog post to generate your full-fledged website.

Before starting the code, you have to prepare a folder with following structure

The above folder structure contains three sub folders, CSS, JS, Images. Since index.html is the main html file that render your website.

All images we will insert into this index.html file will have relative path. Here is the C++ code that will accept three basic information from keyboard and then render the same in our index.html file

C++ code for Generating Website.

#include<iostream>
#include<fstream>
#include<string.h>
using namespace std;
int main(){
	char title[160];
	char heading[180];
	char intro[6000];
	char image[1000];
	
	cout<<"\n\n\n\t\t\t\t WebSIte Builder \n";
	cout<<"\n Website Title :";
	fflush(stdin);
	cin.getline(title,160);
	cout<<"\n Website Heading :";
	fflush(stdin);
	cin.getline(heading,180);
	cout<<"\n Website Introductory Text :";
	fflush(stdin);
	cin.getline(intro,6000);
	cout<<"\n Image Path:";
	fflush(stdin);
	cin.getline(image,1000);
	
	ofstream fout;
	fout.open("index.html");
	fout<<"<html>";
	fout<<"<head>";
	fout<<"<title>"<<title<<"</title>";
	fout<<"</head>";
	fout<<"<body>";
	fout<<"<h1>"<<heading<<"</h1>";
	fout<<"<img src='"<<image<<"'>";
	fout<<"<p>"<<intro<<"</p>";
	fout<<"</body>";
	fout<<"</html>";
	fout.close();
	cout<<"\n Please check your folder ....";
	return 0;
}

How website Builder C++ Program Works

Here we are taking few questions and every user have to answers that questions. Based on the answers of the user we are rendering an Index.html file – basically a text file. The file is your simple website.

What do you need to make website builder using C++

Here are few basic requisite that must be followed if you want to generate website builder using C++

  1. Basic understanding of HTML tags and its coding standard. Your can learn more HTML on w3school.com
  2. File handing in  C++ specially text file handling and how we can re-write a simple text file.

More complex webpages can be generated based on user’s input that can be divided into different choice. We have just shown you the path, its upto you how much complex website builder in C++ you want to create.

Please do share your views on this C++ website builder program using our comment system.

2 thoughts on “Website Generator using C++

Leave a Reply