Thanks about this. I didn't know! I can easily connect myself to Scratch now C:
About the program, I can make it in Panther. It's actually pretty easy when you know the location of the hosts file.
EDIT: Done! Although, you do have to disable Read Only and make the file editable by everyone, as my tests have conclueded. If you're making a program, you're going to have to make it want to run in Administator mode.
Last edited by DigiTechs (2012-10-24 08:53:44)
Offline
I've never worked with IO in C++,but I may make a program designed for modifying the hosts file as I actually want to learn C++.
EDIT: I just got it working, but I need to know how to make char variables hold more than one character >.< Here's my current code:
#include "CustomHostsGenerator.h"
using namespace std;
int main ( )
{
char c;
char v;
cout<<"Please input your desired IP."<<endl;
cout<<"i.e.: 192.168.0.1"<<endl;
cin>>c;
cout<<endl;
cout<<"Now insert your desired hostname."<<endl;
cout<<"ie.: 192.168.0.1 would be router.int"<<endl;
cin>>v;
cout<<endl;
ofstream file;
file.open("C:\\Windows\\System32\\drivers\\etc\\hosts", ios_base::app);
file<<c<<" "<<v;
cout<<"Wrote "<<c<<" "<<v<<" to the hosts file. Enjoy!";
system("PAUSE");
return 0;
};
What it does is, after you get to cin>>c; it only stores 1 character of the ip and then on cin>>v; it stores the 2nd character of the ip. I want it so I can enter as many characters as I want in the c char and the v char.
Last edited by DigiTechs (2012-10-24 11:39:27)
Offline
blob8108 wrote:
Magnie wrote:
You can change it all you want, but anyone outside your network (or that computer itself) won't be able to access domains through that method. My Dad has set up our network so you can type a computer's name (we name all our computers ) instead of the internal IP.
Can't you just use Bonjour/Zeroconf/Avahi? My Macbook automatically broadcasts itself as "hostname.local", for example...
Hmm, forgot about the broadcasting... So at most it would affect the LAN.
Offline
Magnie wrote:
blob8108 wrote:
Magnie wrote:
You can change it all you want, but anyone outside your network (or that computer itself) won't be able to access domains through that method. My Dad has set up our network so you can type a computer's name (we name all our computers ) instead of the internal IP.
Can't you just use Bonjour/Zeroconf/Avahi? My Macbook automatically broadcasts itself as "hostname.local", for example...
Hmm, forgot about the broadcasting... So at most it would affect the LAN.
What would affect the LAN? Bonjour also only works across the LAN, too.
Offline
Does anyone know C++, as my code that I pasted above doesn't work.. *rage* Say I inputted the dragonthunder IP on my code, what I would see in the hosts file is
9 [tab] 6
Replace [tab] with an actual tab, that's what I see.
EDIT: The dragonthunder IP is 96.[etc], not 69.[etc]
Last edited by DigiTechs (2012-10-24 11:45:46)
Offline
DigiTechs wrote:
Does anyone know C++, as my code that I pasted above doesn't work.. *rage* Say I inputted the dragonthunder IP on my code, what I would see in the hosts file is
9 [tab] 6
Replace [tab] with an actual tab, that's what I see.
EDIT: The dragonthunder IP is 96.[etc], not 69.[etc]
Is it "char *c", "char c[]", or some combination of the two?
Disclaimer: I don't know any C.
Offline
blob8108 wrote:
This seems useful.
The problem is, it's in C, which is not C++. The syntax may be the same, but the way you define things and run things is totally different.
EDIT: Oh, and here's my code:
#include "CustomHostsGenerator.h"
using namespace std;
int main ( )
{
char c;
char v;
cout<<"Please input your desired IP."<<endl;
cout<<"i.e.: 192.168.0.1"<<endl;
cin>>c;
cout<<endl;
cout<<"Now insert your desired hostname."<<endl;
cout<<"ie.: 192.168.0.1 would be router.int"<<endl;
cin>>v;
cout<<endl;
ofstream file;
file.open("C:\\Windows\\System32\\drivers\\etc\\hosts", ios_base::app);
file<<c<<" "<<v;
file.close( );
cout<<"Wrote "<<c<<" "<<v<<" to the hosts file. Enjoy!";
system("PAUSE");
return 0;
};
Last edited by DigiTechs (2012-10-24 13:33:06)
Offline
DigiTechs wrote:
blob8108 wrote:
This seems useful.
The problem is, it's in C, which is not C++. The syntax may be the same, but the way you define things and run things is totally different.
Really? My understanding was that C++ is a superset of C, so all C commands work the same in C++ — and C++ just adds extra object-oriented stuff.
Offline
blob8108 wrote:
DigiTechs wrote:
blob8108 wrote:
This seems useful.
The problem is, it's in C, which is not C++. The syntax may be the same, but the way you define things and run things is totally different.
Really? My understanding was that C++ is a superset of C, so all C commands work the same in C++ — and C++ just adds extra object-oriented stuff.
Well, on the page they declared the functions with void, in C++; I have been doing int main ( ) - so yeah. I belive there's a difference.
Offline
DigiTechs wrote:
blob8108 wrote:
DigiTechs wrote:
The problem is, it's in C, which is not C++. The syntax may be the same, but the way you define things and run things is totally different.Really? My understanding was that C++ is a superset of C, so all C commands work the same in C++ — and C++ just adds extra object-oriented stuff.
Well, on the page they declared the functions with void, in C++; I have been doing int main ( ) - so yeah. I belive there's a difference.
"void" and "int" are just the return type of the function... either are valid in both C and C++, afaik.
Offline
blob8108 wrote:
DigiTechs wrote:
blob8108 wrote:
Really? My understanding was that C++ is a superset of C, so all C commands work the same in C++ — and C++ just adds extra object-oriented stuff.Well, on the page they declared the functions with void, in C++; I have been doing int main ( ) - so yeah. I belive there's a difference.
"void" and "int" are just the return type of the function... either are valid in both C and C++, afaik.
Well, even if they are similar, I think of them as two different languages, as it is easier to write code for me when I think 'this is one language, and this is another.' - This excludes XML though, as you can write Lua in XML.
Offline
YAY. My C++ Custom Hosts generator program works. Is there any place I should upload it to that allow you to do it for free? I'm thinking pastebin, but then you would need to compile it yourself.
Offline
Thanks for making it. Do you mind me using some components for my program, which downloads entries off my server?
Offline
Also bobbybee, as I am a complete newbie to C++ and C, I would like to help.
Although, it may be awkeward (Is that spelled right o.o?) that I program in C++, and not C which is what you program in.
Offline
awkward, firstly. And it's only subtle differences.
Offline
bobbybee wrote:
awkward, firstly. And it's only subtle differences.
Thanks for correcting me. And about the subtle differences, what do you mean? Do you mean like things such as variable declaration?
Offline
Well, I'd prefer to do it myself, for organizational reasons.
Offline
Cool. Is there any way to make a fake domain that redirects to a real one?
Last edited by technoboy10 (2012-10-27 15:17:19)
Offline
Not really...
Offline
technoboy10 wrote:
Cool. Is there any way to make a fake domain that redirects to a real one?
Actually, you probably could. Just use some redirect code(there's one somewhere at w3schools.com), and put it at the IP address that you set the fake domain to use. It will redirect you to the real domain.
Offline