1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
5
<meta http-equiv="Content-Language" content="en-us">
6
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
7
<title>Creating your C++ file</title>
8
<link rel="stylesheet" type="text/css" href="../help.css">
13
<h1>Creating your C++ file</h1>
15
<p>You can begin coding your HelloWorld program. The .cpp file that you
16
create will be saved in the project folder you just created
17
<a href="cdt_w_newproj.htm">Creating a Makefile project</a>.</p>
19
<p>Files are edited in the C/C++ editor located to the right of
20
the C/C++ Projects view. The left margin of the C/C++ editor, called the marker
21
bar, displays icons for items such as bookmarks, breakpoints, and compiler errors and warnings.</p>
23
<p>For more information about:</p>
26
<li>The editor area and marker bar, see <b>Workbench User Guide > Reference > User interface
27
information > Views and editors > Editor area</b></li>
28
<li>The marker bar icons, see <b>Workbench User Guide > Reference > User interface
29
information > Icons and buttons > Editor area marker bar</b></li>
31
<p>To create a C++ file:</p>
33
<li>In the <b>Project Explorer</b> view, right-click the <b>HelloWorld</b> project
34
folder, and select <b>New > Source File</b>.</li>
35
<li>In the <b>Source file: </b> field, type <b>main.cpp</b>.
36
<br>By default the source folder should be your project folder.
37
<br>The template selected is probably "Default C/C++ Source Template."
39
<li>Click <b>Finish</b>.</li>
40
<li>A Comment template probably appears at the top of an otherwise empty file.
41
Type the code, exactly as it appears below, in the editor.
42
Or you can paste it in from this help file.
45
#include <iostream>
49
// Say Hello five times
50
for (int index = 0; index < 5; ++index)
51
cout << "HelloWorld!" << endl;
53
cout << "To exit, press 'm'" << endl;
56
cout << "You just entered " << input
57
<< " you need to enter m to exit." << endl;
64
<li>Click <b>File >
68
<p>Your new .cpp file is displayed in the <b>Project Explorer</b> view. Your project now contains main.cpp. Before you
69
can build your HelloWorld project, you must create a makefile.</p>
72
<a href="cdt_w_newmake.htm" style="text-decoration: none">
73
<img border="0" src="../images/ngnext.gif" width="16" height="16" alt="Next icon"></a> <b><a href="cdt_w_newmake.htm">Next: Creating your makefile </a> </b>
76
<p align="left"><a href="cdt_w_newproj.htm" style="text-decoration: none">
77
<img border="0" src="../images/ngback.gif" width="16" height="16" alt="Back icon"></a> <b><a href="cdt_w_newproj.htm">Back: Creating your project</a></b></p>
79
<p><img border="0" src="../images/ngconcepts.gif" ALT="Related concepts" width="143" height="21">
81
<a href="../concepts/cdt_c_projects.htm">CDT projects</a><br>
82
<a href="../concepts/cdt_c_proj_file_views.htm">Project file views</a><br>
83
<a href="../concepts/cdt_o_code_entry.htm">Coding aids</a></p>
84
<p><img border="0" src="../images/ngtasks.gif" ALT="Related tasks" width="143" height="21">
86
<a href="../tasks/cdt_o_proj_files.htm">Working with C/C++ project files</a><br>
87
<a href="../tasks/cdt_o_write_code.htm">Writing code</a></p>
88
<p><img border="0" src="../images/ngref.gif" ALT="Related reference" width="143" height="21">
90
<a href="../reference/cdt_o_proj_prop_pages.htm">C/C++ Projects view</a></p>
93
<img src="../images/ng00_04a.gif" ALT="IBM Copyright Statement" >