Spartan025's - C++ Program Template

Post here about scripting and programming for HaloPC (audio, network, ai, etc.)
Post Reply
Spartan025





Posts: 13
Joined: Fri Oct 13, 2006 3:45 pm
Location: Learning C++

Spartan025's - C++ Program Template

Post 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.

Code: Select all

#include <iostream>
using namespace std;

int main() {
        cout << "Initiate Control Room Console" << endl;
        cout << "Initiate functions......" << endl
        system("PAUSE");
        return 0;
}
Post Reply