Page 1 of 1

Spartan025's - C++ Program Template

Posted: Sun Mar 18, 2007 12:30 pm
by Spartan025
This is a template for which most simple C++ programs works

Here are different kinds of templates i use for exercise or my own apps

Simple

Code: Select all

#include <iostream>
using namespace std;

int main() {
      system("PAUSE");
      return 0;
}
This is a simple template of C++ program all the preprocessors or #includes go at the top.
Any functions go before the using namespace std;

int main() is the main function of the program.
Enter all the C++ statements before system("PAUSE");

Infinite Loop User-Terminated

Code: Select all

#include <iostream>
using namespace std;

int main() {
       while(1) {
             //Statements
             //Somehting to terminate, example press 0 and enter to exit
            // otherwise keep going

      }
      system("PAUSE");
      return 0;
}
Same thing as the one before except is terminated by the user and keeps going unless terminated.

These are just suggested templates for C++ and you do not have to use them but are simple and easy to use.