# Creating your C++ file

You can begin coding your HelloWorld program. The .cpp file that you create will be saved in the project folder you just created Creating a project.

Files are edited in the C/C++ editor located to the right of the C/C++ Projects view. The left margin of the C/C++ editor, called the marker bar, displays icons for items such as bookmarks, breakpoints, and compiler errors and warnings.

For more information about:

- The marker bar, see Workbench User Guide > Reference > User interface information > Icons and buttons > Editor area marker bar
- The editor area, see Workbench User Guide > Reference > User interface information > Views and editors > Editor area

To create a C++ file:

1. In the C++ Projects view, right-click the HelloWorld project folder, and select New > File.
2. In the File name field, type main.cpp.
3. Click Finish.
4. Type the code, exactly as it appears below, in the editor. Lines are indented with tab characters, not with spaces.

> #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);
> }

5. Click File > Save.

Your new .cpp file is displayed in the C/C++ Projects view and in the Navigator view. Your project now contains main.cpp. Before you can build your HelloWorld project, you must create a makefile.

Next: Creating your makefile

Back: Creating your project

CDT projects
Project file views
Coding aids

Working with C/C++ project files
Writing code

C/C++ Projects view