Presentation is loading. Please wait.

Presentation is loading. Please wait.

Compiling a C Program. Before we can begin we must open a telnet session to phobos. There are a number of ways to do this, but the easiest is to click.

Similar presentations


Presentation on theme: "Compiling a C Program. Before we can begin we must open a telnet session to phobos. There are a number of ways to do this, but the easiest is to click."— Presentation transcript:

1 Compiling a C Program

2 Before we can begin we must open a telnet session to phobos. There are a number of ways to do this, but the easiest is to click on Start, then Run, and then type the word telnet and press the Enter key.

3 A window will open on your desktop. This is what it looks like using Win2000. Type open phobos.senecac.on.ca and then press the Enter key. The Win98/95 method is next.

4 When the telnet window opens in Win98/95, click on Connect and then Remote System.

5 Type phobos.senecac.on.ca in the Text Box labeled Host Name, then click on Connect.

6 The procedure is the same from this point using either Win2000 or Win98/95. Enter your user name and then press Enter, and then enter your password and press Enter.

7 Once you have logged on to the system your cursor will be at the command prompt ($). We are going to use a program named nled to create our C source file. Type nled welcome.c at the command prompt and then press Enter.

8 The nled edit window opens in insertion mode. We can just start typing to enter text. Type the code for the C source file and then press the Escape key (Esc) and the x key at the same time to save your file and exit nled.

9 Your cursor will be back at the command prompt after nled closes. Type cc welcome.c and press Enter. phobos will pause for a moment while your file is compiled. When it is finished the command prompt will reappear. Type a.out to see the output of your C program.

10 What Happened? Our source code is a series of instructions that we want to have carried out. Our instructions must be translated in to a language that can be understood by a computer. When we type cc filename.c we are telling the computer we are using to compile our source file, using the C compiler, into an executable file that can be run to produce the desired result. Remember that when we are logged on to phobos using a telnet session that the source file and executable file reside on phobos. The executable file will only work on phobos. To create an executable file that will work on your local machine the source file would have to be compiled locally.

11 What Happened? The default name for an executable file on phobos is a.out. To give your C program another name you must tell the compiler at compile time. If we wanted to name our executable to be named welcome1 the command would be: cc welcome.c -o welcome1 The general format of the compile command is: cc source.c - produces a.out cc source.c -o outputname - produces outputname

12 Summary Open a telnet session to phobos Use nled to create a C source file Use the cc command to create an executable file The default name for the executable file on phobos is a.out Run the executable file by typing its name at the command prompt


Download ppt "Compiling a C Program. Before we can begin we must open a telnet session to phobos. There are a number of ways to do this, but the easiest is to click."

Similar presentations


Ads by Google