Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C 

I've made a program that blocks ads (sort of)

The program in question opens the servers.txt file in the same directory as the .exe and copies it to the hosts file and blocks the ad servers.
You can find it here

The source code (for those that don't want to go to github) is

Code
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()
{
    bool error = 0;
    string line;

    fstream hosts("C:\\Windows\\System32\\drivers\\etc\\hosts", ios_base::app);  //change to C:\\Windows\\System32\\drivers\\etc\\hosts when you've stopped being an idiot


    fstream servers("servers.txt");



    if (hosts.is_open() && servers.is_open())
    {
        while (getline(servers, line))
        {
            hosts << line << '\n';
            cout << line << endl;
        }
        {
            cout << line << '\n';
        }
    }
    else if (!hosts.is_open())
    {
        cout << "Could not open the hosts file." << endl;
        cout << "Please make sure you have run this program as an administrator" << endl;
        error = 1;
    }
    else if (!servers.is_open())
    {
        cout << "Could not open the servers file." << endl;
        cout << "Please make sure the servers file is in the same directory as the .exe file" << endl;
        error = 1;
    }
    else
    {
        cout << "Error, can't open the file" << endl;
        error = 1;
        cout << "Error code 198237" << endl; //make it look like i know why the file won't open
    }


    cout << endl;
    cout << endl;
    cout << endl;
    cout << endl;
    cout << endl;
    cout << endl;
    cout << endl;
    cout << endl;
    if (!error)
        cout << "Welcome to the adfree world" << endl;


    system("PAUSE");
    return 0;

}

Any constructive feedback is appreciated.
Nice program, i will check if i can use it
man, by the way you explained it, I thought it sounded cool, but like lol..

But i mean you're learning so good on yeah haha
Wait I am so confused.. Am I missing like an entire another source code file somewhere I am not seeing....?
Be back.
(Mar 15, 2016 09:31 PM)Ƥeeka Wrote:  Wait I am so confused.. Am I missing like an entire another source code file somewhere I am not seeing....?


Its in the OP xD
This program does literally nothing ahahahaha, man it "blocks adds and everything" lmao
(Mar 15, 2016 09:58 PM)Aker15 Wrote:  This program does literally nothing ahahahaha, man it "blocks adds and everything" lmao

Literally nothing? I don't know, it does paste the stuff from the servers.txt file into the hosts file blocking a lot of ad servers. What do you mean literally nothing?


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by synboxinDec 19, 2018 03:08 AM 9 415 Dec 19, 2018 03:08 AM
Last Post: itcorp
[C] by SigmaMay 2, 2017 03:54 PM 7 186 May 2, 2017 03:54 PM
Last Post: Sigma
[C] by maderaNov 7, 2015 12:41 PM 6 198 Nov 7, 2015 12:41 PM
Last Post: 0xDEAD10CC