Creating your C++ file

 

To create your C++ file

  1. In the C++ Projects view, right-click the HelloWorld project folder and click New > File.
  2. In the File name box, type main.cpp.
  3. Click Finish.
  4. Type the code below in the main.cpp editor.
  5. #include <iostream>
    using namespace std;

    int main () {
    // Say Hello five times
    for (int index = 0; index < 5; ++index)
    cout << "HelloWorld!" << endl;

    char input = 'i';

    cout << "To exit, press ‘m’" << endl;

    while(input != 'm') {
    cin >> input;
    cout << "You just entered " << input
         << " you need to enter m to exit." << endl;
    }

    exit(0);
    }

  6. Click File > Save main.cpp.

Next

Back

Copyright IBM Corporation
 2000, 2002. All Rights Reserved.