Keep main.cpp

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?
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/
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
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
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
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.
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
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
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
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
Which IDE are you using (if any) ?
Most IDEs have templates to start from
im useing microsoft visual studio at home i dont know what i use at school
Which edition?
I don't think you can make your own templates with the Express one
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>
kk i guess i will T_T
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
Learn to touch type. Seriously.

Topic archived. No new replies allowed.