I an a pure programmer by nature. So, it is obvious that I feel to lazy sometimes to do lengthy manual work to block a site without software.  I originally encountered this kind of program written in C on site GoHacking.com. Remember what I said, this program was written in C not in C++. The site omitted that how this program blocked the site. This is not my style of writing. I prefer to tell you aboyut the main logic behind the program. I re wrote this program in C++. 

Firstly, lets talk avout the main logic of the program. If you know there exists a file in location “C:\Windows\system32\drivers\etc” named hosts, it is also called the Mini DNS map of the Windows. When you enter the URL of the web site, you computer first searches over the internet for the DNS info of that site. When it gets there, then you are  ablt to get there. So, This hosts file is the DNS map, it could be used to do 2 works

1)  Faster Browsing, Point the web site to original DNS Server, so no more searching on the net for the DNS.

2)  Blocking a web site, pointing the web site to your own computer, thus computer will never find out the DNS of the web sote, so you will never be able to open the web site until you change the  hosts file , 🙂

The logic of the program is simple. Opening and editing the hosts file according to the name entered by the user. Lets have a look.

#include <fstream>
#include <iostream>

using namespace std;

int main()
    char site[20],ch;
    ifstream in;
    ofstream out;

    cout<<"Enter the Name of the Site to Block \n";

        cout<<"Either File Not Found or Permission Denied, Run as Admin the EXE of the Program";
    return 0;

One thing more. Win 7 users, the generated EXE of the program would not be able to block the site as editing of hosts file in WIn 7 requires Administrative privialages. You can acquire that by running the EXE of the program by right click then. it would work.

The Program does not privde a way to unblock web site, I left that part intentionlly. You can program yourself. However, if you face a problem. Fell free to ask Me.

Good Luck.