carbidecpp22devenv/configuration/org.eclipse.osgi/bundles/309/1/.cp/getting_started/cdt_w_newcpp.htm
author cawthron
Fri, 04 Dec 2009 10:01:33 -0600
changeset 5 684bf18fdedf
permissions -rw-r--r--
add files for RCL_2_2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     2
<html lang="en">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     3
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     4
<head>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     5
	<meta http-equiv="Content-Language" content="en-us">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     6
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     7
	<title>Creating your C++ file</title>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     8
	<link rel="stylesheet" type="text/css" href="../help.css">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
     9
</head>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    10
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    11
<body>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    12
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    13
<h1>Creating your C++ file</h1>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    14
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    15
<p>You can begin coding your HelloWorld program. The .cpp file that you  
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    16
create will be saved in the project folder you just created
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    17
<a href="cdt_w_newproj.htm">Creating a Makefile project</a>.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    18
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    19
<p>Files are edited in the  C/C++ editor located to the  right of 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    20
the C/C++ Projects view. The left margin of the C/C++ editor, called the marker 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    21
bar, displays icons for items such  as bookmarks, breakpoints, and compiler errors and warnings.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    22
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    23
<p>For more information about:</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    24
<ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    25
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    26
  <li>The editor area and marker bar, see <b>Workbench User Guide &gt; Reference &gt; User interface 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    27
  information &gt; Views and editors &gt; Editor area</b></li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    28
    <li>The marker bar icons, see <b>Workbench User Guide &gt; Reference &gt; User interface 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    29
  information &gt; Icons and buttons &gt; Editor area marker bar</b></li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    30
</ul>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    31
<p>To create a C++ file:</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    32
<ol>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    33
  <li>In the <b>Project Explorer</b> view, right-click the <b>HelloWorld</b> project 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    34
  folder, and select <b>New &gt; Source File</b>.</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    35
  <li>In the <b>Source file: </b> field, type <b>main.cpp</b>.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    36
  <br>By default the source folder should be your project folder. 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    37
  <br>The template selected is probably "Default C/C++ Source Template." 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    38
  </li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    39
  <li>Click <b>Finish</b>.</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    40
  <li>A Comment template probably appears at the top of an otherwise empty file.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    41
  Type the code, exactly as it appears below, in the editor. 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    42
  Or you can paste it in from this help file.
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    43
</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    44
<pre>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    45
#include &lt;iostream&gt;
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    46
using namespace std;
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    47
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    48
int main () {
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    49
    // Say Hello five times
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    50
    for (int index = 0; index < 5; ++index)
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    51
      cout << "HelloWorld!" << endl;
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    52
    char input = 'i';
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    53
    cout << "To exit, press 'm'" << endl;
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    54
    while(input != 'm') {
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    55
        cin  >> input;
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    56
        cout << "You just entered " << input
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    57
             << " you need to enter m to exit." << endl;
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    58
    }
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    59
    exit(0);
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    60
}
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    61
</pre>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    62
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    63
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    64
  <li>Click <b>File &gt; 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    65
  Save</b>.</li>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    66
</ol>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    67
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    68
<p>Your new .cpp file is displayed in the <b>Project Explorer</b> view. Your project now contains main.cpp. Before you 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    69
can build your HelloWorld project, you must create a makefile.</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    70
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    71
<p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    72
<a href="cdt_w_newmake.htm" style="text-decoration: none"> 
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    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>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    74
</p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    75
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    76
<p align="left"><a href="cdt_w_newproj.htm" style="text-decoration: none">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    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>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    78
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    79
<p><img border="0" src="../images/ngconcepts.gif" ALT="Related concepts" width="143" height="21">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    80
<br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    81
<a href="../concepts/cdt_c_projects.htm">CDT projects</a><br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    82
<a href="../concepts/cdt_c_proj_file_views.htm">Project file views</a><br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    83
<a href="../concepts/cdt_o_code_entry.htm">Coding aids</a></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    84
<p><img border="0" src="../images/ngtasks.gif" ALT="Related tasks" width="143" height="21">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    85
<br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    86
<a href="../tasks/cdt_o_proj_files.htm">Working with C/C++ project files</a><br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    87
<a href="../tasks/cdt_o_write_code.htm">Writing code</a></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    88
<p><img border="0" src="../images/ngref.gif" ALT="Related reference" width="143" height="21">
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    89
<br>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    90
<a href="../reference/cdt_o_proj_prop_pages.htm">C/C++ Projects view</a></p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    91
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    92
<p>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    93
<img src="../images/ng00_04a.gif" ALT="IBM Copyright Statement" >
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    94
</body>
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    95
684bf18fdedf add files for RCL_2_2
cawthron
parents:
diff changeset
    96
</html>