473,385 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

block unblock a site not working

#include <fstream.h>
#include <iostream.h>
#include <string.h>
int main()
{
char site[20],c,d;
ifstream in; ofstream out;
cout<<"press 1 to block website & press 2 to open website";
cin>>d;
switch(d)
{
case 1:
{
cout<<"Enter the Name of the Site to Block \n";
cin>>site;
out.open("C:/Windows/System32/drivers/etc/hosts",ios::app);
if(!out)
cout<<"Either File Not Found or Permission Denied, Run as Admin the EXE of the Program";
else
out<<"127.0.0.1"<<"\t"<<site;
out.close();
return 0;
}
case 2:
{
cout<<"Enter the Name of Website to open \n";
cin>>site;
out.open("C:/Windows/System32/drivers/etc/hosts",ios::app);
if(!out)
cout<<"Either File Not Found or Permission Denied, Run as Admin the EXE of the Program";
else
out.replace(out.find(site),site.length()," ");
out.close();
return 0;
}
case default:
cout<<"wrong choice dude run exe again";
}}
Jul 9 '14 #1
2 1230
weaknessforcats
9,208 Expert Mod 8TB
The path is not correct for Windows:

Expand|Select|Wrap|Line Numbers
  1. out.open("C:/Windows/System32/drivers/etc/hosts",ios::app);
This is a Linux path.

The Windows path is:
Expand|Select|Wrap|Line Numbers
  1. out.open("C:\\Windows\\System32\\drivers\\etc\\hosts",ios::app);
Jul 9 '14 #2
Try
Expand|Select|Wrap|Line Numbers
  1. out<<"127.0.0.1"<<"\t"<<site << endl;
  2.  
Jul 10 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Asad_Zaidi | last post by:
I have a website developed in ASP.NET and Content Management Server. This site's home page has a textbox which takes say an ID as input. The entered ID is then posted as a querystring to another...
0
by: Sune Hansen | last post by:
Hi guys, I really hope someone can help me with my problem. Here is the scenario: I have a development environment on my locale machine. Once in a while when everything has been tested I...
0
by: Rico Alexander | last post by:
I get all types of errors when creating a asp.net app in visualstudio and copying it to a earthlink host. Their windows server seem to be running asp.net 1.0. Anyone able to get their asp.net...
5
by: NEWBIE in ABQ | last post by:
I have developed a WEB Application using Visual Studio VB.NET and it runs well on my development computer. I would like to run it from my personal WEB Page provider by my Internet Provider. I...
1
by: babar | last post by:
plz tell me how can i(admin) block and unblock users using checkbox?
71
by: Murray R. Van Luyn | last post by:
Hi, Since I have made changes to my website it's been a complete flop. According to the logs, as soon as visitors have downloaded the index page they are off. I can't figure out why? ...
3
by: WSPL5 | last post by:
I have a hidden span within a table column and I cannot unhide it using style.display='block' ?? Sample code <table> <tr> <td><input name="status" value=""></td><td><input type="button"...
3
by: Ritwik Kumar | last post by:
Hi, can you please help me sort out this problem..... a site http://www.kuliza.com/ open quite well if Internet explorer is used but if firefox is used display is not as desired.... wat could...
1
by: AllBeagle | last post by:
Hello All, I have a .NET 4.0 web application that I'm trying to get working on a GoDaddy shared hosting plan. It's their best windows one and from a requirement point of view on paper they have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.