Lab Assignment 1

Step One - Login

To use the Linux system, you login to a Linux computer using your acc.yourusername. Your Linux account is created automatically. See http://www.birdnest.org/linux.asp

You connect to Linux using a secure shell connection such as ssh or puTTY. (You can get PuTTY on your computer from the web page above.) In the campus labs, click on Start, Programs, CSCI Programming, Putty. Choose putty to a city name for one of the Linux systems (austin, chester, etc. But use reno when off campus). When you see the login prompt, type in your username in the format with the prefix "acc.", for example, acc.browns3. At the Password prompt type in your password that you have used on the Winthrop computers and for Winthrop email.

If you forget your password, go to the Information Technology web site at http://www.winthrop.edu/technology/, click on the Student Services option, then on Password Reset. It should send you to the site at https://asap.winthrop.edu/studentaccount/changepassword.aspx which allows you to change your password.

To log off the Linux system by typing exit at the Linux prompt.

 

Step Two - Review VI

Read the seperate web page that explains how to use the vi editor. This information is provide in a seperate page so that you may easily refer back to it.

More information about basic vi can be found in your lab textbook on pages 172-179.

 

Step Three - Editing your Source Code

Create a file named hello.cpp containing the following:

     // Program file:  hello.cpp
     //***********************************************
     //          Your Name
     //          CSCI  208
     //          Lab Exercise 1
     //
     //          Program prints "Hello world!" to the screen
     //
     //**********************************************

     #include  <iostream>
     using  namespace  std;
     int  main ( )
     {
          cout  <<  "Hello world!"  <<  endl;
          return  EXIT_SUCCESS;
     }

 

Step Four - Compile, Link, and Run

To run your source code you must first convert your source code into machine code. That conversion is a two step process. First, you create an object file. Then you link your object file to the system's library files to create an executable file.

The commands to compile and link your file named hello.cpp are:

     c++ -c hello.cpp
     c++ -o hello hello.o
If all went okay, you should now have a new executable file named hello.

To run your new program, type the name of the executable file:

     hello

 

Step Five - Creating Printouts

Now, we will create a script file that contains the program output so that it can be turned in. To do so, type in the following:

     script  lab1.log
     hello
     ctrl-d
Note, ctrl-d means hold down the control key and press the d key. crtl-d is the end-of-file character.

You should have a new file named lab1.log. To print the log file and your source code:

     lpr ‑Pthur301 lab1.log
     lpr -Pthur301 hello.cpp

 

Step Six - Turn in Your Work

Staple your two pages together and turn them in at the beginning of the next lab period.