Keep main.cpp

Nov 12, 2009 at 6:06pm
is there a way to keep your main so you dont have to type
1
2
3
4
5
6
7
8
9
#include <iostream>
using namespace std;

int main ()
{
	system ("PAUSE");
	return 0;
	
}

every time?
Nov 12, 2009 at 6:07pm
closed account (S6k9GNh0)
1) Don't use system: http://www.cplusplus.com/forum/articles/11153/
2) We have an article showing you how to do this: http://www.cplusplus.com/forum/articles/7312/
Nov 12, 2009 at 6:15pm
thats not what i mean i want it so every time i create a new application my main.cpp is created with the application so i dont have to keep typing the code in my first post
Nov 12, 2009 at 6:17pm
closed account (S6k9GNh0)
You aren't by any chance writing this in console are you? Are you compiling this in a file? The compiled code produces an executable which you can execute as many times as you want without problems. What do you mean?
Last edited on Nov 12, 2009 at 6:18pm
Nov 12, 2009 at 6:19pm
im sorry for not knowing much about c++ im writeing it in the .cpp but i dont wish to type it every time i create a new program
Nov 12, 2009 at 6:25pm
closed account (S6k9GNh0)
Well it's not the same everytime you create a program which is why you must type it. If you don't have the patience to type the int main() function, you probably shouldn't be a programmer.
Nov 12, 2009 at 6:28pm
its not just the main() its createing a new main every time at my school the main is already created for us every time we start a new cpp file
Nov 12, 2009 at 6:45pm
This is an odd request... we're talking maybe 30 seconds to create a main.cpp and associated main function. If that's pissing you off, then get ready for a lifetime of pain programming... Additionally, it's only a problem you will encounter while learning. If you program as a career you most likely won't be making very many main functions if any at all.
Last edited on Nov 12, 2009 at 6:47pm
Nov 12, 2009 at 7:01pm
it dosent do anything to me im just not used to it i downloaded a version of c++ at home and unlike at school i have to create the mains myself i was just wondering if there was a way to make it more like my school its a different version on c++ so i dont know if thats it or not i would just like to save me those 30 seconds if possible
Nov 12, 2009 at 7:05pm
ts a different version on c++


Different version? What IDE/Compiler are you using at school and at home? I haven't tried this myself, but I believe MS Visual C++ provides the ability to create Project/Solution Templates... but from what I've read it will take you longer to set this up than it would to create 200 main.cpp files and type in the code yourself.

Edit: Too slow in my edit :)
Last edited on Nov 12, 2009 at 7:10pm
Nov 12, 2009 at 7:07pm
Which IDE are you using (if any) ?
Most IDEs have templates to start from
Nov 12, 2009 at 7:11pm
im useing microsoft visual studio at home i dont know what i use at school
Nov 12, 2009 at 7:25pm
Which edition?
I don't think you can make your own templates with the Express one
Nov 12, 2009 at 7:28pm
I'd just say get used to it. It literally only takes a few seconds to type that up. And as you get further in your classes your #include section will include a lot more than just <iostream>
Nov 12, 2009 at 7:40pm
kk i guess i will T_T
Nov 12, 2009 at 7:41pm
Don't worry the more you program the faster your typing will become. Although I mainly use four fingers (left index, left middle, right index, and right middle finger my Word Per Minute is at 51. =) I really should learn to use all my fingers.

Last edited on Nov 12, 2009 at 7:42pm
Nov 12, 2009 at 7:55pm
Learn to touch type. Seriously.

Topic archived. No new replies allowed.