Professional Documents
Culture Documents
Instructor: ChaoChao-Ching Ho
National Yunlin University of Science and Technology
Overview
Office Hours
Classroom
http://sites.google.com/a/smartrobot.co.cc/robot/courses/programming
Class Forum
http://groups.google.com/group/2009programming?hl=zh-TW
Textbooks
Textbook:
References:
C .
C/C++().
C, , .
A Book on C (Programming in C), 4th Edition, Al
Kelley and Ira Pohl, Addison-Wesley.
Literature
A Book on C:
Programming in C
Reference
4th edition
C Programming Language
2nd Edition
Reference
Grading
Homework (20%)
Course Topics
)
)
)
)
)
Mid-term Exam
Storage Class ()
Structure and Union ()
Disk File I/O ()
Laboratory ()
8051 Microcomputer (8051)
Serial Communication ()
8x8 LED Experiment (LED)
System Call and Windows API(Windows API)
Overview
C Environment (C
Data Type and Variable (
Operator and Expression (
Flow Control (
)
Laboratory (
)
Function and Macro (
Pointer and Array (
Presentation
Image Processing
Animation
Computer Graphics
Automatic Optical Inspection
Robotic
3D Scanning technology
Financial engineering
Control engineering
Computers
Computer Architecture
5661
5662
5663
5664
5665
5666
5667
5668
5669
Address
bus
Main memory
Data bus
Input devices
CPU
Output devices
Secondary memory
Software
01
System Program
Application Program
(Operating System)(Compiler)(Assembler)
(Linker)
Office
Programming Language
Generations
Machine Languages
Assembly Languages
High Level Languages
Application-Generation Languages
Query Languages
Logic-Oriented Languages
Machine Language
Machine Language
01
01
01
01
Low-level Language
01
Assembly
Language
01
INCIncrement
8051
00000100
10000100
8051
INC
DIV
8051
x86
x86
0000001111001000
ADD CX,AX
101110010011010000010010
MOV CX,1234H
CX1234H
x86
CPU
0
1
CPU
CPU
High-level Language
10
compilerinterpreter
(machine independent)
portable
AB
B
B
Batch
object file
execute file
CC++gccg++VC++
BCBPascalObject PascalDelphiKylix
ANSI-Cmath
math
11
JavaScriptVBScriptPython
12
Visual
C/C++
Basic Java Object Pascal C#
C/C++
C/C++
C
C++
C/C++Linux/Windows/MS-DOS/Mac
JavaVirtual Machine
C/C++
8051
C
C/C++
13
CC++
C++C
C++
C++C
C++
History of C Language
CDennis Ritchie1972
CC
BKen ThompsonB
Martin RichardsBCPL
CUNIX
1973UNIX
C
14
History of C Language
C
C
C
C++CC++
History of C Language
CC
UNIXC
UNIXCC
CC
CCC
C10
10C
CANSI-C
15
History of C Language
B
C++Java C#
C
31
Structured Programming
16
Modules
Modules
Libraries
Libraries
ToolboxC
C
Information
Hiding
17
Object Programming
Object
C
C
forwhilegoto
CgotoC
goto
C
18
Bjarne StroustrupC(OOD
Object-Oriented Design)C++C++
Object-Oriented Program LanguageOOPL
C++CC++
Object-Oriented Programming
OOP
(attribute)
(behavior)OOPproperty
methodC++
C and C++
CC++C++
C
C++C
C++
C++OOPC++
CC++
CC
C++C
C
19
Advantages of C Language
Advantages of C Language
C
C
CC
CC
CC
CPreprocessor
20
C (1/4)
interpreter
compiler
C C++FortranPascal
41
C (2/4)
C
BASIC
( )
21
C (3/4)
( )
C (4/4)
( )
22
Advantages of C Language
1.
(portable)
2.
(cross-platform)
3.
4.
(pointer)
5.
C
( )
23
( )
24
( )
25
Debugging
If you make a mistake of syntax in your code
(e.g. leaving out a semicolon), the compiler will
always tell you the first line where it sees a
problem often the line after the problem
actually occurred. Dont be discouraged by a
long stream of error messages fix the first one,
and the others often disappear.
semantic
error
syntax error
(de-bug)
bug
http://www.computersciencelab.com
52
26
C/C++
CC++
C/C++
Step1
C/C++
WindowsLinuxVimpico
.c.cppC
.cC++.cpp
Step2
GCCgcc/g++
object file
Step3
Step4
27
Compiler
Compiler (cont.)
28
Compiler (cont.)
(1)(scanner)
(token)
(lexical analysis)
(regular expression)
(finite state machineFSM)
1-3
A~Z
0A~Z0~9
ID == [A-Z][A-Z0-9]*
Compiler (cont.)
29
Compiler (cont.)
(2)(parser)
(syntax analysis)
(grammar)C
compound-statement:
{ declaration-listopt statement-listopt }
declaration-list:
declaration
declaration-list declaration
statement-list:
statement
statement-list statement
Compiler (cont.)
(intermediate
representationIR)
Cc=a+b;
CC
a,b,c
30
Compiler (cont.)
one-pass
compiler
Compiler (cont.)
(Pre-Processor)
31
C Language Coding
C
C++ C
01
02
03
04
05
06
07
08
09
10
11
/* prog1_1,
C
*/
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
printf("Hello C!\n");
printf("Hello World!\n");
/*
/*
Hello C! */
Hello World! */
system("pause");
return 0;
}
32
Thanks you.
33