If not,then don't waste your time. But maybe you want to learn some C++ BASICS
This is a step by step,easy to read and understand tutorial. It is for people who just started to learn C++ ,i think :-s
It is a basic program,with no GUI.
Let's Start!
1.First,we need our python code. Here you can find it:
Now,we have our code. I would copy it into a notepad and let it opened-up,cause we will need to use it many times.
2.Lets start up your C++ IDE. I like to use,for those basics programs, MinGW / Code::Blocks . You can use any. Now,start a new project file,with a c++ source file.you'd better make your proj file on a folder on desktop,so you will find your porgram easy.
3. Let's start the coding. First, we will need to include 2 libraries:
Code:
#include<iostream> #include<fstream>
Code:
using namespace std; int main()
First,let's tell the program to create our file... ( it will be an empty file!)
Code:
fstream f("logininfo.py",ios::out);
After this,we will need to define some variables and some characters:
Code:
int n,c,s,a,b,a2; char pass[50],id[50];
5.Now,if you look at our code,we have something like
Code:
serverNum=
Code:
id=
Code:
cout<<"username="; cin>>id;
And so on:
Code:
cout<<"password="; cin>>pass; cout<<"Server number="; cin>>n; cout<<"Channel="; cin>>c; cout<<"Character slot="; cin>>s; cout<<"If you want to be logged in automatically, tipe 1. Else, type 0 "; cin>>a; cout<<"If you want your character to be autoselected,type 1. Else, type 0"; cin>>a2;
6.Now,the user has just entered all his data to create the .py .... now,let's enter them in the .py file....
The first code line was: fstream f()
now,we will use the "f" to read or write in our file.
to write something,actually the firrst line,we will type:
Code:
f<<"import serverInfo"<<endl;
And,so on!
Code:
f<<"import serverInfo"<<endl; f<<"serverNum = "<<n<<endl; f<<"serverChannel = "<<c<<endl; f<<"id = "<<id<<endl; f<<"pwd = "<<pass<<endl; f<<"Slot = "<<s<<endl; f<<"autoLogin = "<<a<<endl; f<<"autoSelect = "<<a2<<endl; f<<"addr = serverInfo.REGION_DICT [0] [serverNum] ["channel"] [serverChannel] ["ip"]"<<endl; f<<"port = serverInfo.REGION_DICT [0] [serverNum] ["channel"] [serverChannel] ["tcp_port"]"<<endl; f<<"account_addr = serverInfo.REGION_AUTH_SERVER_DICT [0] [serverNum] ["ip"]"<<endl; f<<"account_port = serverInfo.REGION_AUTH_SERVER_DICT [0] [serverNum] ["port"]"<<endl;
But if you will compile it,you will see something is wrong.Actually,the mistake is here:
Code:
["channel"]
Code:
f<<"addr = serverInfo.REGION_DICT [0] [serverNum] ["channel"] [serverChannel] ["ip"]"<<endl;
To write it with quotes,we will ned to add some " / "...
Like here:
Code:
[\"channel\"]
Code:
f<<"import serverInfo"<<endl; f<<"serverNum = "<<n<<endl; f<<"serverChannel = "<<c<<endl; f<<"id = "<<"\""<<id<<"\""<<endl; f<<"pwd = "<<"\""<<pass<<"\""<<endl; f<<"Slot = "<<s<<endl; f<<"autoLogin = "<<a<<endl; f<<"autoSelect = "<<a2<<endl; f<<"addr = serverInfo.REGION_DICT [0] [serverNum] [\"channel\"] [serverChannel] [\"ip\"]"<<endl; f<<"port = serverInfo.REGION_DICT [0] [serverNum] [\"channel\"] [serverChannel] [\"tcp_port\"]"<<endl; f<<"account_addr = serverInfo.REGION_AUTH_SERVER_DICT [0] [serverNum] [\"ip\"]"<<endl; f<<"account_port = serverInfo.REGION_AUTH_SERVER_DICT [0] [serverNum] [\"port\"]"<<endl;
7. Now,let's just close the file:
Code:
f.close(); return 0;
Here is our final code:
8.After this,your compiled program will look like:
You can download it from here:
I really hope i helped you !