Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

[Program]Save 10 seconds of your life.

$
0
0
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:
#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:
#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/>

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>