1 CS 240 Programming in C and UNIX Lecturer: Bob Wilson Office: S-3-071 Phone: 617-287-6475

Slides:



Advertisements
Similar presentations
Introduction to the Omega Server CSE Overview Intro to Omega Basic Unix Command Files Directories Printing C and C++ compilers GNU Debugger.
Advertisements

ENEE150: Discussion 1 Section 0104 Please Sit Down at a Computer and Login!
C Programming for engineers Teaching assistant: Ben Sandbank Home page:
CSCI 1411 FUNDAMENTALS OF COMPUTING LAB Lab Introduction 1 Shane Transue MSCS.
1 Introduction: Unix and C Software Project – Winter 2007 / 2008.
Course Introduction and Getting Started with C 1 USF - COP C for Engineers Summer 2008.
1 Introduction: Unix Software Project – Autumn 2008/2009.
CMPE 151: Network Administration Spring Class Description Focus: system and network administration. Sequence of exercises. E.g., installing/configuring.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
CSE : Programming in C Instructor: Lei Wang Office: Dreese Lab 474 Office Hour: Friday.
Introduction to C Topics Compilation Using the gcc Compiler
Introduction to C. A Brief History Created by Dennis Ritchie at AT&T Labs in 1972 Originally created to design and support the Unix operating system.
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction What is Unix? An operation system (OS), similar to Windows, MacOS X Why learn Unix? Greatest Software.
The Unix Environment and Compiling. Getting Set Up Your programs will be compiled and tested on the Departmental server ‘linprog’ The linprog servers.
CS110/CS119 Introduction to Computing (Java)
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Introduction to Shell Script Programming
Essential Unix at ACEnet Joey Bernard, Computational Research Consultant.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
1 SEEM3460 Tutorial Unix Introduction. 2 Introduction Unix-like system is everywhere Linux Android for smartphones Google Chrome OS for Chromebook Web.
Computer Programming for Biologists Oct 30 th – Dec 11 th, 2014 Karsten Hokamp  Fill out.
1 Agenda Administration Background Our first C program Working environment Exercise Memory and Variables.
CS 6560 Operating System Design Lecture 3:Tour of GNU/Linux.
LINUX Tuesday, 5 July :00 pm. Remote Login l Use Secure Shell (ssh) l Machine name/IP address E.g. ssh hydra.sma.nus.edu.sg Or ssh
Programming With C.
CS 444 Introduction to Operating Systems
CPSC 217 T03 Week I Part #1: Unix and HELLO WORLD Hubert (Sathaporn) Hu.
CMSC 104, Version 9/011 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program 104 C Programming Standards and Indentation.
Introduction to C Programming Lecture 2. C Tutor Schedule / 3rd Floor Lab b The lab and tutor schedule is available at the following URL:
Algorithms  Problem: Write pseudocode for a program that keeps asking the user to input integers until the user enters zero, and then determines and outputs.
CGS 3460 Why we choose UNIX n Powerful lMulti-user operating system lGood programming tools Most heavy-duty database management systems started out on.
Basic Unix Commands CGS 3460, Lecture 6 Jan 23, 2006 Zhen Yang.
Creating Programs on UNIX This term you can create programs on UNIX or you can create programs using a C++ compiler on your PC. This set of slides steps.
Introduction to Programming Using C An Introduction to Operating Systems.
CMSC 104, Lecture 111 Introduction to C Topics l Compilation l Using the gcc Compiler l The Anatomy of a C Program l 104 C Programming Standards and Indentation.
1 Homework Done the reading? –K&R –Glass Chapters 1 and 2 Applied for cs240? (If not, keep at it!) Gotten a UNIX account? (If not, keep at it!)
Department of Electronic & Electrical Engineering Introduction to C - The Development cycle. Why C? The development cycle. Using Visual Studio ? A simple.
ENEE150: Discussion 1 Section 0104/0105 Please Sit Down at a Computer and Login!
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
1 Introduction to Unix. 2 What is UNIX?  UNIX is an Operating System (OS).  An operating system is a control program that helps the user communicate.
A Brief Overview of Unix Brandon Bohrer. Topics What is Unix? – Quick introduction Documentation – Where to get it, how to use it Text Editors – Know.
Announcements Assignment 1 due Wednesday at 11:59PM Quiz 1 on Thursday 1.
Introduction to UNIX and Linux.  Written by Dennis Ritchie and Ken Thomsom at Bell Labs in 1969  Initially written in assembly language and a high-level.
Dr. Sajib Datta Jan 16,  The website is up.  Course lectures will be uploaded there ◦ Check regularly for assignments and update.
General Computer Science for Engineers CISC 106 Lecture 03 James Atlas Computer and Information Sciences 6/15/2009.
CS 120 Extra: The CS1 Server Tarik Booker CS 120.
L071 Introduction to C Topics Compilation Using the gcc Compiler The Anatomy of a C Program Reading Sections
Assignprelim.1 Assignment Preliminaries © 2012 B. Wilkinson/Clayton Ferner. Modification date: Jan 16a, 2014.
Review Why do we use protection levels? Why do we use constructors?
Introduction to C Topics Compilation Using the gcc Compiler
ENEE150 Discussion 01 Section 0101 Adam Wang.
UMBC CMSC 104 – Section 01, Fall 2016
Introduction to C Topics Compilation Using the gcc Compiler
Creating Programs on UNIX
Introduction to C Topics Compilation Using the gcc Compiler
C Programming Lecture Series
Andy Wang Operating Systems COP 4610 / CGS 5765
CS 444 Introduction to Operating Systems
Computer Systems Programming
Andy Wang Operating Systems COP 4610 / CGS 5765
Creating your first C program
Andy Wang Operating Systems COP 4610 / CGS 5765
CS 240 Programming in C Lecturer: Ramin Dehghanpoor Office: S-3-134
CS 444 Introduction to Operating Systems
Andy Wang Operating Systems COP 4610 / CGS 5765
CSE 303 Concepts and Tools for Software Development
Video Notes.
Andy Wang Operating Systems COP 4610 / CGS 5765
CSCE 206 Lab Structured Programming in C
Introduction to C Topics Compilation Using the gcc Compiler
Presentation transcript:

1 CS 240 Programming in C and UNIX Lecturer: Bob Wilson Office: S Phone:

2 Course Objectives This course will teach you C Programming It also covers several other related topics: –UNIX Commands –Compiler and Debugger –MAKE and Makefiles –UNIX File System and File Access –UNIX Processes and Shells/Shell Scripts

3 Motivation C is the language of choice for systems programming and embedded systems Number of Programmers by Language: –COBOL3 million –Visual Basic1.5 million –C/C++1.1 million Mastery of the material in this course may enable you to get a high paying job!

4 Introduction Syllabus and Lecture Notes –Web: Required Textbooks –The C Programming Language, 2nd Ed., Kernighan & Ritchie –UNIX for Programmers and Users, 2nd Ed., Glass & Ables

5 Introduction HW assignments –Assignment write-ups will be on my website –But HW must be done on our UNIX systems! All Homework MUST BE an Individual Effort –You can answer questions for each other as long as you acknowledge any help that you receive from others –BUT DON’T HAVE OR LET ANYONE ELSE DO YOUR HOMEWORK FOR YOU! –Don’t change the owner, group, or mode on any of your homework directories or files!! (NO chown, chgrp, chmod!) –If I discover any cheating, I’ll follow school policy!

6 Getting Started Fill out the CS240 Student Survey Form on the web page as soon as possible UNIX Account –Apply for CS240 ASAP! –(Science 3 rd Floor UNIX Lab) Use Sun Blades in UNIX Lab Access to UNIX systems from your home PC –Secure internet access is required now! –Can not use TELNET or FTP for remote access! –Must use Secure Shell 2 for remote access –Can use Putty or SSH Communications S/W packages

7 Getting Started (SSH 2) Putty (Officially Recommended by Systems Staff) – (Non Commercial Downloads) –Download: SSHSecureShellClient exe SSH Communications (Recommended by me) – –Download Non-Commercial Version (.exe for Windows) –Or –Download and Execute Installer executable Student Recommended – (Windows) – (MAC OS X)

8 Getting Started (Editor) Editing source files is a requirement Learn to use a UNIX editor program –vi: a simple visual editor described in Glass –emacs: a more complex visual editor that can also be used as a complete development shell (also described in Glass) –pico: a simple text editor based on the pine program ( I personally like this one!)

9 Getting Started ( ) Use the UNIX program pine for your Pine is supported by system staff – UNIX mail program is not. Type command “man pine” for pine user documentation Type command “pine” to access

10 Communication You must monitor course web site and your UNIX account for announcements!! To contact me: –Office: S –Office Hours: Posted on my website UNIX: finger bobw – –Phone/Voice Mail: (617) (UMB) –or (508) (Home) only if really stuck!

11 Java versus C CS110 (Java) is a prerequisite for CS240! Java and C are both “block structured” languages –Compound statements defined by braces { } –Similar if-else, for/while loops, expressions, etc Java is Object-Oriented, C is only procedural Java and C syntaxes look deceptively similar However, many small annoying differences –Close but different semantics/syntax can be confusing –Learn C as a different language – not just like Java! –C99 is a bit closer to Java, but we’re not using it here!

12 Java versus C Java Compiler / Interpreter –Java source is compiled to byte code file (.class) –Byte code file is then interpreted by JVM –JVM is written in native machine code –Interprets program slower than native machine code C Compiler / Linker –C source is compiled to object file(s) –Object file(s) is/are linked to create an executable file –Executable file runs as native machine code –Executes program faster than interpreting byte code file

13 C programming You will be learning to write, execute, and debug C language programs in this course We will not be just modifying programs that have already been written and debugged!! We will spend most of the time in class on the C language, MAKE, and the debugger This is the primary material for tests/quizzes Use Kernighan and Ritchie (K&R) textbook!!

14 UNIX Operating System You will be using UNIX to edit, compile, debug, and run your C programs. We will not spend as much time in class on UNIX. You must learn to use UNIX as you go You can be held accountable for UNIX on exams Use UNIX Guide and Glass textbook Also can refer to the Umass Boston Website: –

15 Basic UNIX Commands (Responsible for these next time) cat display a file on your terminal screen (see also “more”) cdchange directory cpcopy a file logoutlogout from your account lprprint a hard copy lslist files in a directory man xxxmanual page for command xxx moredisplay a file on your terminal screen - one page at a time mvmove a file from one place to another mkdircreate a new subdirectory pwdprint working directory (pathname of directory you’re in) rmremove (delete) a file rmdirremove (delete) a directory CTRL-c“Control” key and “c” key together – stop current command

16 UNIX File System Directory Sub-directory File bobw ~bobw/cs240 ~bobw/cs240/hw0 ~bobw/cs240/hw0/assignment ls cd cs240cd.. rm filename New Sub-directory mkdir pwd

17 Hello World! Your first homework project is to create and run a C program – “Hello World!” (K&R, p5+) Create a source file “hello.c” in one of three ways –Use Unix Systems in UNIX Lab with vi, pico, or emacs –Use Putty/SSH on PC to access UNIX with vi, pico, or emacs –Use Notepad on your own PC and transfer the file Use “gcc” to compile and create a file named “hello” Run “hello” to see the printout on screen Use a “typescript” file to turn in assignments

18 hello.c (K&R, Page 6) /* hello.c: first homework assignment name: your name date: xx/xx/xx */ #include int main( ) /* we’ll ignore arguments to main for now */ { printf(“Hello World!\n”); return 0; }

19 C Source - Comment Lines Comment text is ignored by the compiler /* This is a multi-line comment. The compiler ignores both lines. */ Be sure to include the closing “*/” /* This is a multi-line comment int main ( ) { printf (“Hello World!”); return 0; } /* terminated by this -> */

20 C Source - #include … Because this program uses the Standard I/O Library, it needs to include In C programming, a “.h file” defines –Macros (e.g. Names for constants) –Prototypes for functions (e.g. printf itself) “gcc won’t compile “hello.c” with “printf” function without the “#include ”

21 C Source – Main Declaration “int main ( )” is the function where the UNIX system starts execution of your program Your function’s code is within “braces” { } Braces are usually placed on their own lines { function statements are here; }

22 C Source - printf The Standard I/O Library provides you with a function named “printf ( )” “printf ( )” prints argument as text on screen Argument is the text between the parentheses (“Hello World!\n”) “\n” is a C convention for “end of line” (For open book tests, remember K&R page 193) All C program statements end with a “;”