Lab 1 Beginning C Program



Similar documents
Linux Overview. Local facilities. Linux commands. The vi (gvim) editor

Tutorial Guide to the IS Unix Service

CPSC 226 Lab Nine Fall 2015

University of Toronto

QUICK START BASIC LINUX AND G++ COMMANDS. Prepared By: Pn. Azura Bt Ishak

Instructions for Accessing the Advanced Computing Facility Supercomputing Cluster at the University of Kansas

WinSCP PuTTY as an alternative to F-Secure July 11, 2006

Unix Guide. Logo Reproduction. School of Computing & Information Systems. Colours red and black on white backgroun

PuTTY/Cygwin Tutorial. By Ben Meister Written for CS 23, Winter 2007

Laboration 3 - Administration

General Computing Network (GCN) Guide for Mac OS X

FileZilla: Uploading/Downloading Files to SBI FTP

POLARIS INSTALLATION

Getting the most out of your new Aalto workstation An Aalto IT guide for personnel migrating to the new Aalto workstation environment

There s a variety of software that can be used, but the approach described here uses freely available Cygwin software: (1) Cygwin/X (2) Cygwin/openssh

Sky Broadband upgrading your router software

Downloading and Installing Core FTP

1 Basic commands. 2 Terminology. CS61B, Fall 2009 Simple UNIX Commands P. N. Hilfinger

Using Keil software with Linux via VirtualBox

Running your first Linux Program

How to Connect to Remote Desktop & How to Use Cisco AnyConnect Secure Mobility Client Secure VPN Connection

Technology Business Solutions. Online Backup Manager INSTALLATION

Uploads from client PC's to mercury are not enabled for security reasons.

Personal Portfolios on Blackboard

File Management and File Storage

Lab 0: Preparing your laptop for the course OS X

Guide to the Configuration and Use of SFTP Clients for Uploading Digital Treatment Planning Data to ITC

Guide to the Configuration and Use of SFTP Clients for Uploading Digital Treatment Planning Data to IROC RI

Command Line - Part 1

Remote Access to Unix Machines

Beyond Windows: Using the Linux Servers and the Grid

Home and Shared Folders on Windows Accessing Home and Shared Folders on Active Directory File Servers Using Windows

Connecting to the School of Computing Servers and Transferring Files

Accessing vlabs using the VMware Horizon View Client for OSX

Accessing your Staff (N and O drive) files from off campus

Introduction to Operating Systems

SSH Connections MACs the MAC XTerm application can be used to create an ssh connection, no utility is needed.

ICS 351: Today's plan

Accessing the FTP Server - User Manual

UOG User Guide. Windows

VCL Access. VCL provides access to Linux and Windows 7 Virtual Machines. Users will only see those images that they are authorized to access.

Linux Labs: mini survival guide

Mapping ITS s File Server Folder to Mosaic Windows to Publish a Website

QUT PRINTING SERVICES. Printing from your laptop. Connect your laptop to the student print queue

Raspberry Pi Setup Tutorial

SSH Secure Client (Telnet & SFTP) Installing & Using SSH Secure Shell for Windows Operation Systems

Citrix Client Install Instructions

Using Internet or Windows Explorer to Upload Your Site

WS_FTP Pro for Windows 95/98/NT

1. Open Thunderbird. If the Import Wizard window opens, select Don t import anything and click Next and go to step 3.

How to Give Admin Rights to Students on the ADGRM Domain

Recommended File System Ownership and Privileges

Lab 5 Managing Access to Shared Folders

2 Advanced Session... Properties 3 Session profile... wizard. 5 Application... preferences. 3 ASCII / Binary... Transfer

sftp - secure file transfer program - how to transfer files to and from nrs-labs

Download and Install the Citrix Receiver for Mac/Linux

VPN - AnyConnect on Windows

Installation Guidelines (MySQL database & Archivists Toolkit client)

CS 103 Lab Linux and Virtual Machines

Posting Job Orders. mindscope Staffing and Recruiting Software

Chapter 2 Text Processing with the Command Line Interface

Linux Connection Guide. by Tristan Findley

OFFICE 365 SELF- CONFIGURATION GUIDE

Using the GroupWise Client

MATLAB on EC2 Instructions Guide

Unix Sampler. PEOPLE whoami id who

Parallels Panel. Parallels Small Business Panel 10.2: User's Guide. Revision 1.0

VPN Remote Access Installation and Configuration Guide Operating System: Windows (XP, Vista, 7 and 8)

SparkLab May 2015 An Introduction to

Client Configuration Guide

Introduction to the MISD Web FTP Client

Installing Sun's VirtualBox on Windows XP and setting up an Ubuntu VM

Creating a Website with Publisher 2013

Attendance Monitoring. Academics: Accessing your Register. v 0.6, September Masood Syed, Dev Team, ITMS. Masood Syed, Dev Team, ITMS

TM Online Storage: StorageSync

Server Installation: ServerTools

Hosting Users Guide 2011

Setting Up Scan to SMB on TaskALFA series MFP s.

SSH and Basic Commands

Outlook Web App User Guide

Check current version of Remote Desktop Connection for Mac.. Page 2. Remove Old Version Remote Desktop Connection..Page 8

Primavera P6 Professional Windows 8 Installation Instructions. Primavera P6. Installation Instructions. For Windows 8 Users

PC Instructions for Miller LiveArc Software

Configure Single Sign on Between Domino and WPS

How to use SURA in three simple steps:

6. After connecting reopen the wireless connections window. Right click on RamNet and select properties. Page 2 of 7

To install the "Microsoft Remote Desktop Client" on OS X "Tiger" or above:


Welcome to Collage (Draft v0.1)

Remote Desktop Web Access. Using Remote Desktop Web Access

SOS SO S O n O lin n e lin e Bac Ba kup cku ck p u USER MANUAL

Installing Proview on an Windows XP machine

How. to: Connect Remotely. Updated by

Connecting to Remote Desktop Windows Users

Adobe Dreamweaver - Basic Web Page Tutorial

Microsoft OneDrive. How to login to OneDrive:

IBI Group FTP: Usage Instructions

Cloud Server powered by Mac OS X. Getting Started Guide. Cloud Server. powered by Mac OS X. AKJZNAzsqknsxxkjnsjx Getting Started Guide Page 1

Installation Guide. Research Computing Team V1.9 RESTRICTED

Transcription:

Lab 1 Beginning C Program Overview This lab covers the basics of compiling a basic C application program from a command line. Basic functions including printf() and scanf() are used. Simple command line concepts are also practiced. Finally practice with the online submission system is emphasized. Prelab Please be aware that for most labs the student needs to have completed the Prelab prior to the lab time. Many prelabs require the student to turn in some evidence of completing the Prelab. Additionally, most weeks there will be a short in lab reading quizzed based on the Prelab questions. Students should be sure they are prepared prior to lab. For this lab, a Prelab is not required. Prelab Quizzes Normally, every week there will be a Prelab quiz given the first 5 minutes of lab. This quiz is closed book and must be completed by 5 minutes after the hour. Don t be late to lab. Procedure Software tools For the first few labs, the course will be covering some of the basic concepts of C using command-line techniques. This type of programming is bare bones meaning that it is as close to the process of compiling code possible where individual steps in the process can be seen. Another type of programming environment (program) is an integrated development environment (IDE). These are very common in modern programming but often cost SIGNIFICANT amounts of money to purchase and use. Figure 1: Simple model for developing software. The basic process of compiling code, figure 1, is outlining what needs to be done, writing the code, compiling and linking, and testing. Starting out, you will be using a text editor program (not a word processor) to write your code. On windows, Notepad++ is recommended and is what will be used in these examples. On Mac, choose your favorite tool and Gedit is recommended for Linux. A link for the Notepad++ is available on the lab webpage. To compile the code, we will be compiling on a remote system. This remote system is called flip.engr.oregonstate.edu or lovingly called flip for short. To access flip, you need an SSH Terminal program. Putty is 5 P a g e

recommended for windows and the default terminal can be used on mac or Linux. A link for the putty is available on the lab webpage. Finally to make it easier to work on files in windows, a tool for mapping network drives should be installed. On the ENGR computers in the labs this is done automatically. The Z drive is a mapped drive to the location on flip used in this lab. Mapping a Network Drive using a Windows Laptop If you would like to use your own laptop for this course (recommended) setting up a windows network drive is simple. NOTE: The mapped drive will only work while the laptop is connected to the OSU Wireless network. Open Computer and select Map Network Drive : From the Start menu navigate to Computer, found on the left quick navigation bar. This can also be found by opening the Start menu and selecting Computer From the choices on the right. Once here click on Map Network Drive, which should be the forth entry on the under the navigation bar, Figure 2. Figure 2: Enter in the network address of your engineering home folder. Select a drive letter from the drop down menu for your engineering home folder to be mounted, the default is the Z: drive. Then enter the network address of your home folder (without brackets): \\stak.engr.oregonstate.edu\[your_engineering _Username] Finally select Connect using different credentials and Reconnect at Logon press Finish, Figure 3 Figure 3 Step 3: Enter in your Engineering Credentials Username: ENGINEERING\[Your Engineering Username] Password: Your Engineering Password After selecting OK, there will be a new drive under Computer from the Start menu. Figure 4 6 P a g e

Create directories and download files To get started, the directory for the code needs to be created on the flip server. To do this you must have an ENGR account. If you have not set one of the up prior to this course, please consult your TA to get direction how to do it. To login into flip, open up Putty, (or another SSH application), figure 5, and fill in the address information. Remember, you may need to download putty from the lab webpage to use it! Host Name: flip.engr.oregonstate.edu The first time a connection is made the software will ask if it is ok to use and store a public key, figure 6. Allow the connection and enter the user name and password when requested (no figure). Figure 5: Select the default terminal (usually [XTERM]) by pressing [ENTER] when asked, figure 7. A prompt will be displayed, figure 8, type bash and press enter. Note: Things that should actually be typed into the keyboard will appear in bold. cd Change Directory cd.. Change Directory Up a Level ls List Directory Contents mkdir Make Directory pwd Present Working Directory Figure 6: Figure 7: Figure 9: Figure 8: 7 P a g e

Working at the command line is different than using a graphical user interface because it allows for much faster control and execution of programs. Just like with a graphical interface, the hardest thing is learning where the different programs are located. The find programs and files, rather than using the mouse and selecting icons, commands are typed into the command window and directories are navigated. Figure 9 has a list of common commands, but for now type mkdir ece151 and press enter. Note: After any command pressing enter is required to make the command operate. It will not be mentioned in the rest of the document. Run the following sequence of commands, figure 10: cd ece151 mkdir lab1 cd lab1 pwd Figure 10: Example of output after running commands The present working directory (pwd) command shows what directory the user is currently in. In the example, the directory will be different, but the last part /ece151/lab1 must be the same for the following commands to work. Download the lab1 files from the lab webpage. Unzip them into the directory created above. This can be done by using the windows file explorer and navigating to your Z: drive. Once there, you can navigate to the \ece151\lab1 directory. After the files are unzipped, type ls into the putty window to get a directory listing. Entering C code In the directory there is a c file called main.c Open this file with Notepad++ for entering code. Once it is open, enter the code snippet below and save the file. #include <stdio.h> int main (void) { printf("hello CS/ECE 151!\n"); return 0; } There are several special characters in this code snippet that are important to the C language. Notice the semicolons at the end of each command. These must be there to tell the compiler that the command is complete. Also notice the curly braces ( { and } ) and how there is the same number of open braces ( { ) and closed braces ( } ). These braces enclose blocks of code that are run together. For example in this code snippet, the printf() and return() statements are both part of the main() function. 8 P a g e

Compile C file After entering the code snippet for lab 1, the next step would be to compile. On most systems there is a process to compiling and linking. There are often many steps to be taken. Often these steps are put into a makefile so that a single command can be used to compile and link. The command for this is make all try it at the command line. The code should compile without errors. The resulting compiled program is ready to run. To run it enter labprogram into the command window. Introduce an Error Notice that each line has a line number that helps to locate specific lines easily. When errors are found in the code by the compiler the line number of the error is displayed so it can be founds easily in the code. To understand this, introduce an error by deleting the semicolon from the end of line with the printf() statement. Save the file and go back to the putty program. Ensure that the present working directory has /ece151/lab1 at the end. Run the make all command. Examining the output, an error should be visible, figure 11. Compile C File Figure 11: Example of a compilation error. Working from the initial program supplied, edit the program to print out the following text. Make sure the program prints out information that is specific to you, not the exact information below: User: heer Name: Donald Heer Favorite Color: Blue Demonstrate and Submit C File For every lab assignment, two things must be done. First, the directory where the code is found (eg. lab1) must be zipped into a file and submitted via the TEACH interface prior to the end of lab time. Additionally by the end of lab, the working code must be demonstrated to the lab TA for the course. To get credit for the lab, both tasks must be accomplished. The assignment name for this submission is: TEACH Assignment Name: Lab1 Before having the teaching assistant come to see the demonstration of the code, ensure that the program has already been started and that source code is already open for the TA to inspect. 9 P a g e

Study Questions Many of the labs will have assigned study questions. When assigned, the answers to the study questions should be printed out and handed into the TA the lab following. If no study questions are assigned, nothing would be turned in along with the demonstration. 1. In your own words, what are each of the following Linux commands; pwd, cd, rm, cp, mkdir, rmdir, and ls. 2. Where is the computer science freshman mentor lounge? What is the poster of on the wall? Extended Learning Extended learning is an opportunity for you to try out some new things and take your knowledge to the next level. You are not required to do anything under the extended learning section. However, if you do successfully finish all of the extended learning sections for the course by their due dates, you can choose to opt out of the final for the course as long as you have a C average or better on the other tests in the course. What to do The extended learning challenge for this first lab is to explore how to use the function scanf() to take in three variables; username, first name, and favorite color. Once the user has entered all three items, the program should print them out in the same format as in the above lab. Demonstrate and Submit C File with Comments For every extended learning assignment, two things must be done. First, the directory where the code is found (e.g. lab1) must be zipped into a file and submitted via the TEACH interface prior to the beginning of lab time the following week. Additionally at the beginning of the next week s lab, the working code must be demonstrated to the lab TA for the course. To get credit for the lab, both tasks must be accomplished. The assignment name for this submission is: TEACH Assignment Name: Lab1Extra Lab Summary Install Software (Optional) Task Completed? Download and compile sample code Introduce an error and see output Modify code to print new information and demonstrate Extended Learning demonstration (Optional) 10 P a g e