Shell and C Basics

Last time: Compiling / Intro to using UNIX

Prof. Brian D. Davison

Computer Science & Engineering, Lehigh University

Additional Credits

Announcements

Using the Shell

I use tcsh instead of bash because that is what I learned; again, like editors, shell choice is often a 'religious' issue.

Comparison to DOS/Windows shell

UNIX Commands 1

PWD=Print Working Directory CD=Change Directory

UNIX Commands 2

Be careful about rm -rf! LS=LiSt (files or contents of a directory) RM=ReMove

Viewing Files

You can always open a text file in an editor to view it. However, there are other ways -- cat, less, and more are typical choices.
less and more are called pagers -- they display a large file, one page (screenful) at a time.

C Programming

Note the man page sections for the system calls. Use man -s to specify which section of the manual pages to search.

C versus C++

Do the students know?

Major C differences from C++

Other Differences

So what stays the same? Glad you asked...

Basic C Data Types

int is signed, 32 bits on typical (but not all) platforms. float typically 32bits, double typically 64, long double 128

Operators

As always, multiplication and division have precedence over addition/subtraction; use parenthesis to make things clear

Assignment Operators

Type Conversions

Type Conversions continued

Quick test: what is the result of 1.0 + 3/2?

Control Flow

Control Flow

Looking Ahead