Download - Introduction to String matching
C Programming
MTRX 1702 – Software Component
04/07/23 1Introduction
Who am I?• Dr David K Wood• Australian Centre for Field Robotics (ACFR) • Room: ACFR field Lab, Ground Floor, EE Building• Availability: Limited outside of lectures.• Phone: 90366398• Email:[email protected]
• Graduate of USYD Mx Degree (2005)
04/07/23 2Introduction
Lectures and Labs• Lectures:
– Wednesday 12-13 (Civil Eng LR3)
• Labs: 2 hours per week – Wednesday 2-4– Thursday 2-4– Friday 9-11
• NO LAB CHANGES!– If you really need something changed, come see me after
the lecture
04/07/23 3Introduction
Tutors
• Lachlan [email protected]
• Nasir [email protected]
• Me - [email protected]
04/07/23 4Introduction
Textbooks‘Prescribed’ Textbooks:• Bailey, T. An Introductory Course on C Programming and Software Design
This text is by an earlier lecturer for this course, and still follows the lecture schedule quite well. It is available online at:
www-personal.acfr.usyd.edu.au/tbailey/ctext• Deitel, H.M. and Deitel, P.J., C: How to Program. 3rd Ed.
An alternative introductory textbook. Very simple. Many code examples.
Recommended Textbooks:• Harbison, S.P. and Steele G.L., C: A Reference Manual
One of the definitive reference handbooks. Not a learning textbook.• Oualline, S. Practical C Programming
An alternative introductory textbook. Simpler than K&R. Quite good.• Kernighan, B.W. & Ritchie, D.M. The C Programming Language. 2nd Ed.
The textbook you will probably turn to as you gain experience. Written by the creator of C (Ritchie), it is authoritative and complete.
04/07/23 5Introduction
Other Resources
• It is highly recommended to get a compiler and development environment for home
• Visual Studio– ‘Real’ version is large, expensive and under-utilised– ‘Other’ versions are insecure and unreliable!– Express Edition is FREE from the MS website, and has the same
functionality as the laboratory machines.• Other Dev Environments– If you’ve used something before, feel free to use it again.– All marking will be on V.S. 2010
04/07/23 Introduction 6
04/07/23 Introduction 7
Course Information
• Course material accessible from AMME website.
www.aeromech.usyd.edu.au/MTRX1702/Course_Material/
• Look at the software engineering component for:– Lecture slides– Lab material– Assignments– On-line resources– News
04/07/23 8Introduction
Class Diversity• I expect a wide range of diversity regarding familiarity with
programming concepts and C. – Some will be quite proficient.– Some will be complete novices.
• We have a lot to cover in this course and will move quickly.– Everything you need to know will be explained in lectures and labs, but you
will need to work hard to keep up.• Please ask questions if there is anything you don’t understand.
– If you don’t ask, I won’t know that you don’t know.• Remember that many aspects of programming will become clearer
by looking at example code and doing the labs.
04/07/23 9Introduction
Feedback
• Please provide feedback– Problems with course material or presentation– Problems with labs– Constructive criticism (or praise)
• Do so by sending me an email• If you want something fixed or desire some modification
of the course, let me know sooner rather than later
04/07/23 10Introduction
My Expectations
By undertaking this subject, the student is committing to:• Learn the subject, not just memorize notes.• Attend all lectures, with the aim of learning and
understanding, not just note taking.• Attend all laboratory sessions, with the aim of maximizing
your understanding of the course material.• Study this topic for at least 1 hour per week outside of
allocated class time.• Being familiar with, and adhering to the University’s
policies, in particular the policy on academic honesty.
04/07/23 11Introduction
What You Can Expect
• I am willing to help anybody that has attempted to first help themselves
• I do not give out answers, I help you to understand the problem
• You are free to ask questions at any time here in the lectures, in the labs, or via email
• Let me know immediately if things are not going well and we will attempt to resolve any issue.
04/07/23 12Introduction
• Attend lectures and labs. • Read the lecture notes. Read ahead and come to class
prepared.• Read the lab sheet in advance.
– Work through lab questions in the allotted time.– Ask questions if you don’t understand. – Keep up to date.
• Experiment with writing and debugging code during labs. – This is an essential part of gaining an understanding of the C language
and its use.
• Submit assignments that are neatly presented and on time.
04/07/23 13Introduction
How to Do Well
Assessment
• Lab Attendance (5%)• Two Assignments (50%)• Two-hour Exam (45%)
• Each week (starting in Week 2) lab-work is given. – Attending and participating in labs is compulsory.– Understanding code and writing programs is the only way to learn to program.– This is not a course that you can cram in stu-vac.
• Experiment with code-modules during labs. Use the debugger.• Work through the labs and lectures, and the exam will be simple!
04/07/23 14Introduction
Why Learn C?After all, C is over 30 years old. There are other newer languages now.
1. C will be the language used in several later courses.2. C compilers exist for almost all platforms, so your code can be readily
ported and run anywhere.3. C is high-level, yet “close to the machine”. So, it is commonly used in
embedded programming.4. C remains the language of choice in many other areas also. For example,
systems programming, graphics, numerics, real-time control, etc. Thus, it means real jobs.
5. There exists a huge base of existing C code that must be maintained. Again, real jobs.
6. There exists a huge number of open-source libraries for C. This code is often of excellent quality and can be used directly in your project.
04/07/23 15Introduction
Course Objectives
• Introduce the C programming language as a practical programming tool.
• Introduce the basic concepts of software design.– Learn to design, code, and debug complete C programs.– Learn how to decompose large problems into manageable
systems of modules. Design for correctness, flexibility, extensibility, maintainability.
04/07/23 16Introduction
Where will you have trouble?
• “We’ll discuss that in <DELAY> weeks time.”– We have 13 1-hour lectures interspersed with labs– Make good use of Textbooks– Don’t try to understand everything at once
• How do I solve <ISSUE>?– The first 2 labs are designed to familiarise you with the
environment.– TAKE NOTES! A Lab-book is highly recommended.– Check back on your own material before you ask the tutors.
04/07/23 Introduction 17
Brief History of ANSI/ISO C• C pioneered by Dennis Ritchie at AT&T Bell Labs, early ‘70s• Most early C compilers based on an appendix in the 1st Edition
of Kernighan & Ritchie – so called K&R C.• K&R C has some unspecified details: it is has aspects that are
ambiguous and incomplete.• Many incompatible dialects of C were appearing, hindering
portability.• ANSI committee X3J11 formed in 1983 to standardise C; they
reported in 1989.• International ISO standard in 1990.• See paper by Ritchie (1993) for more information on the history
and philosophy of C.• The ISO standard was revised in 1999 giving us C99.
04/07/23 18Introduction
C Language Overview• General purpose language: used for writing software in many
different domains (compilers, graphics, games, embedded systems, etc)
• A “small” language - 32 keywords • With a small level of experience, can expect to know, and regularly
use, the entire language.• Provides modern “high-level” control constructs: decisions, loops,
functions.• Provides “low-level” capabilities: manipulate characters (bytes) and
addresses.
04/07/23 19Introduction
How can the Language be so Small?• It relies on library functions:
– no operations that deal directly with composite objects (e.g. strings, lists, arrays, matrices, collections)
– no memory management facilities (apart from static definition and stack allocation). – no input or output facilities (eg, print to the screen, write to a file, etc)
• These operations require explicitly called functions.– eg, many languages provide a keyword to print to the screen (eg, Fortran has a
PRINT instruction).– The C language has no such keyword, and we use the standard library function
printf() to print.• C comes with a standard library that provides a collection of commonly used
functions (145 of them).• All C programs are composed of functions, and we will cover functions
extensively in this course.
04/07/23 20Introduction
Some Example Programs
• hello.c: a traditional first program• hello2.c• tempf.c• tempf2.c
#include <stdio.h> int main(void) {
printf("Hello, world!\n"); /* Print ‘Hello World to screen */return 0; /* Return Success */
}
04/07/23 21Introduction
How does C work?
04/07/23 22Introduction
What does that actually mean?
04/07/23 Introduction 23
• Scripting Languages require the script engine to be installed:– MATLAB– Java– Python
• Cannot run without additional infrastructure.
MyCode
ScriptEngine
OperatingSystem Hardware
Get rid of the Engine
04/07/23 Introduction 24
• Instead of executing our code within a scripting engine, we compile to an executable.
• Two major savings:1. Efficiency – Compile happens before runtime2. Portability – No longer need engine
MyCode
My Program
OperatingSystem Hardware
Why stop there???
04/07/23 Introduction 25
• Get rid of the operating system altogether• My program directly interfaces to the hardware and
thus to the real world!• Common in embedded systems.• MTRX2700, MTRX3700, MTRX4730 and your own
hobby work
MyCode
My Program Hardware
Homework• Get a copy of the lecture notes off the web. • Review chapters 1 and 2 of lecture notes. (Today's lecture and
next lecture)• Decide on and purchase a textbook.• Look into getting some sort of development environment on a
home/personal computer.
• Lecture notes contain many small code snippets. These might be more understandable as complete working programs, which, for Chapters 1 – 3, can be found on the textbook webpage.
04/07/23 26Introduction