We'll now set up the project with some files that demonstrate features of the CrossStudio IDE. For this, we will add one pre-prepared and one new file to the project.
Adding an existing file to a project
We will add one of the tutorial files to the project. To add an existing file to the project, do the following:
- From the File menu, click Add Existing File.
—or—
- Type Ctrl+D.
—or—
- In the Project Explorer, right click the Tutorial project node.
- Select Add Existing File from the context menu.
When you've done this, CrossStudio displays a standard file locator dialog. Navigate to the CrossStudio installation directory, then to the tutorial folder, select the fact.c.
Now click OK to add the file to the project. The Project Explorer will show fact.c with a shortcut arrow because the file is not in the project's home directory. Rather than edit the file in the tutorial directory, we'll take a copy of it and put it into the project home directory:
- In the Project Explorer, right click the fact.c node.
- From the popup menu, click Import.
The shortcut arrow disappears from the fact.c node which indicates that the file is now in our home directory.
We can open a file for editing by double clicking the node in the Project Explorer. Double clicking fact.c brings it into the code editor:
Removing a file from a project
We do not need the main.c file that the new project wizard added to the project, so we will remove it. Click main.c in the Project Explorer and do one of the following:
- On the Project Explorer tool bar, click the Delete tool button
—or—
- From the Edit menu, click Delete.
—or—
- Type Del.
Alternatively, to remove main.c from the project using a context menu, do the following:
- In the Project Explorer, right click main.c.
- From the context menu, click Remove.
Adding a new file to a project
Our project isn't complete as fact.c is only part of an application. We'll add a new C file to the project which will contain the main() function. To add a new file to the project, do the following:
- From the Project menu, click New File.
—or—
- On the Project Explorer tool bar, click the Add New File tool button.
—or—
- In the Project Explorer, right click the Tutorial node.
- From the context menu, click Add New File.
—or—
- Type Ctrl+N.
The New File dialog appears.
- Ensure that the C File (.c) icon is selected.
- In the Name edit box, type main.c.
The dialog box will now look like this:
Click OK to add the new file. Because main.c already exists on disk, you will be asked whether you wish to overwrite the file:
Click Yes to overwrite the file and continue with the tutorial. CrossStudio opens an editor with the new file ready for editing. Rather than type in the program from scratch, we'll add it from a file stored on disk.
- From the File menu, click Insert File or type Ctrl+K, Ctrl+I.
- Using the file browser, navigate to the tutorial directory.
- Select the main.c file.
- Click OK.
Your main.c file should now look like this:
Next, we'll set up some project options.