Introduction to C Programming Lecture 2

advertisement
Introduction to C
Programming
Lecture 2
C Tutor Schedule / 3rd Floor Lab

The lab and tutor schedule is available at
the following URL:
• http://www.cocse.unf.edu/cislab/
What is telnet?

telnet is a utility program that allows you to
create and execute programs on a remote
machine. You will need to “telnet” into
osprey (our UNIX machine) to work on your
programs from home.
What is FTP?

The file transfer protocol (FTP) is a utility
program that allows you to transfer files
from one machine to another.
• You will use FTP to transfer files from Osprey to
your home machine and vice versa.
Better Telnet and FTP Programs

I found the telnet and FTP
programs that I am now use on my
home computer at:
• www.vandyke.com

The telnet program is called “CRT”
and the FTP program is called
“Absolute FTP”. They provide
graphical user interfaces.
What is an Algorithm?

An algorithm is a step-by-step procedure
for accomplishing some task.
• Step 1
• Step 2
• Step 3
Do Something
Do Something
Do Something
.
.
.
• Step N
Stop, you are finished.
What is Computer Science?
 Computer
science is the
study of algorithms.
• Studying the behavior of algorithms
to determine if they are correct and
efficient.
• Designing computer systems that are
able to execute algorithms.
• Designing programming languages that
allow formal expression of
algorithms.
• Translation of algorithms into
programming languages so they can be
executed by the hardware.
Software Engineering
Define the Problem
 Analyze the Problem
 Design a Solution
 Write the Code
 Test the Code
 Implement the Solution

Structured Analysis, Design, and
Programming
Break the problem down until
you have a collection of
easy-to-solve subproblems.
 Address each subproblem along
with its interface to the
overall problem.
 Develop algorithms that can
be expressed in a computer
language.
 Write your code in a
consistent, easy-to-read,
easy to modify style.

General Computer Organization


Central Processing Unit
Memory
• Main Memory
– RAM (Random Access Memory)
– Where your program is while it is
executing
• Registers
– Where computations, etc. actually
take place
• Secondary Storage
– Disk Storage
– Where you save your files (programs
and data) so they are not lost when
the computer is turned off
Categories of Software

Systems Software
• Operating Systems, Compilers,
Editors, etc.

Applications Software
• Accounting Systems, Report
Generators, etc.

Firmware
• Systems software embedded in ROM
(Read Only Memory)
What is an Operating System?

An operating system is a
collection of software
programs that control access
to the machine.
• DOS, UNIX, & Windows are
examples.

Normally you don’t do
anything on a computer
without using the operating
system.
What is a Compiler?
A compiler is a program that translates the
source code (the program you write using
an editor) into the machine language that
the computer can execute.
 We are using the gcc compiler that is
available on the UNIX operating system.

The Process of Programming

After you have developed an
algorithm to solve the
problem:
• Use an editor such as vi or
Pico to convert the algorithm
into your source code (the
program you write).
• Compile the source code to
create an executable program
file.
• Execute the program by typing
the name of the executable at
the operating system prompt.
What If it Doesn’t Work?

Debugging the Program
• Observe the messages that the
compiler displays.
• Use your editor to look at the
code you wrote.
– Try using the compiler messages to
locate and correct errors.
• After correcting errors, you
must recompile your code and
execute it again.
Common UNIX Commands (1)
 cat
• Display a file
 cd
• Change to another working
directory
UNIX Commands (2)
 chmod
• Set access mode for a file
or directory
–$ chmod 700 /home/phigbee
• The above command will allow
me to read, write, and
execute files in my
directory.
• Students should set the
access mode on their home
directory the same way.
UNIX Commands (3)

lpr
• Print files

ls
• Display information about files

mkdir
• Make a directory

more
• Display a file one screenful at
a time.
UNIX Commands (4)

mv
• Move or rename a file

rm
• Remove a file

rmdir
• Remove a directory

pwd
• Show pathname of working
directory
UNIX Commands (5)

logout (exit or lo on our
system)
• Exit UNIX

kill
• Terminate a process

passwd
• Assign or change a password.

ps
• Display process status
UNIX Commands (6)

who
• Display names of users

who am I
• Display login information about you
Download