Adding a C Source File

After Creating a New Project, you can add source files, then build and run your completed project. Follow these steps to add a hello.c source file to the helloworld project.

  1. From the Eclipse* File menu, select New > File. Enter hello.c in the File name text box of the New File dialog. Click Finish to add the file to the helloworld project.  

  1. Your Eclipse Preference settings in Window > Preferences > Workbench let you specify Perform build automatically on resource modification. If this preference is checked, Eclipse/CDT will attempt a build when hello.c is created. Since hello.c does not yet include code, errors are indicated in the Tasks view and C-Build view near the bottom of the screen. This is expected behavior, not a true error. Select Window > Show View > C/C++ Projects to view the project files.

  1. In the Editor view, add your code for hello.c. If you close hello.c in the Editor view, you can open it by doulble-clicking on hello.c in the Navigator view.

When your code is complete, save your file using File > Save, then proceed to Building a Project.