Hello! I've made a program that creates a "main.cpp" in a new project.It is useful for time saving I think :) The code that is written in "main.cpp" is taken from a "sc.txt" file,located in the folder with the program.You can change the content from the sc file anytime.So here is the code,you have to modify just one line I think:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#include <iostream>
#include <fstream>
#include <string>
#include <Windows.h>
using namespace std;
int main(){
system("title patch_v2.exe");
string pname,tname;
string stmp,st;
fstream cpp,source;
cout<<"Enter project name: ";
getline(cin,pname);
while(pname.empty()){
cout<<"Enter a valid project name : ";
getline(cin,pname);
}
tname="C:\\Documents and Settings\\user name\\My Documents\\Visual Studio 2010\\Projects\\"+pname+"\\"+pname+"\\main.cpp";
// here ^^
cpp.open(tname,ios::out);
source.open("sc.txt",ios::in);
if(!cpp) {
cerr<<endl<<"Unable to open project."<<endl;
Sleep(1000);
return 0;
}
if(!source) {
cerr<<endl<<"Unable to open source file."<<endl;
Sleep(1000);
return 0;
}
while(getline(source,stmp)){
st+=stmp+"\n";
}
cpp<<st;
cpp.close();
source.close();
cout<<endl<<"Ready to write in."<<endl;
Sleep(700);
return 0;
}
|
0.Modify the beginning of the line 19 with the address of your VC++ projects.
1.Now build the program and copy it on the desktop(for example).
2.Create a file "sc.txt" on the desktop and write in it something,for example:
1 2 3 4 5 6 7
|
#include <iostream>
using namespace std;
int main() {
system("pause");
return 0;
}
|
3.Open compiler,select new project.
4.Open the program,write in the projects name.
5.In the compiler select Source file->Add->Existing item and open main.cpp.
Ready-you saved 10 seconds of your life ;).
Of course you can edit the sc.txt file to something longer.
Hope this helped anybody :D