Home
Netbeans Eclipse Qt Java
Games
College of Engineering Aeronautics and Astronautics Agricultural and Biological Engineering Biomedical Engineering Chemical Engineering Civil Engineering Construction Engineering and Management Electrical and Computer Engineering Engineering Education Engineering Professional Education Environmental and Ecological Engineering Industrial Engineering Materials Engineering Mechanical Engineering Nuclear Engineering
EPICS (Engineering Projects In Community Service) First-Year Engineering Program First-Year Engineering Honors Program Global Engineering Program Minority Engineering Program Professional Practice (Co-Op) Program Women in Engineering Program
College Administration Schools Programs All Groups All People ECN Webmail
Purdue Home

ECE 264 Exercise 1

Programming Environment

 

Please read guideline first.

There are many ways to write, compile, and execute C programs.  This exercise shows two examples.  We will use the following code as the example.

 

Importance of semicolon: Sometimes, one missing semicolon can trigger hundreds of error messages. When this happens, do not panic. Check the program and add the needed semicolon.

Compile in Shell

Use your preferred editor to type the program. You are encouraged to use emacs or xemacs, not vi. Save the file and call it ece264.c. To compile this program, type

                          gcc ece264.c -o ece264

We use gcc compiler.  The input is the file you just created. The flag -o specifies the output file name. After executing this command, an executable file is created and its name is ece264.  The following screenshot shows that the file is an executable (by using the file command). Here, "[(ECE264) ~/]" is the shell prompt.

 

The output of the "file" command can be different on different computers. For example, msee190pcxx are 64-bit machines.

To execute the program, type

                   ./ece264

The leading "./" means the file in the current directory. The program terminates and nothing happens.  You immediately see the shell prompt again.

Let's give some parameters

                   ./ece264 hello purdue ece 264

The program will print

                  hello

                  purdue

                  ece

                  264

in four different lines.

Compile using Eclipse

Eclipse is an integrated development environment (IDE) based on Java. Eclipse has been ported to many operating systems, including Linux and Windows. Start eclipse, and select File - New - Project ... A dialog box appears

 

Select C project and click Next. Give "ece264" as the Project name and click Finish.

 

 In Navigator, use the right mouse button and select New - Source File. Call it main.c.

Click Finish. Type the code shown at the top.

 

In the menubar, select Project - Build All. In Navigator, select ece264, use the right moue button and choose Run As - Local C/C++ Application. Nothing appears because we did not give any input argument. Use the right mouse button again and choose Run As - Open Run Dialog.

Add four arguments: hello, ece, 264, purdue. Click Apply and Run. Now, you can see the arguments printed as the program's output (called Console).

 

What to Submit?

In Blackboard, type "I have followed the instruction in Exercise 1 and understand how to write, compile, and execute C programs."