CPC Programmi ng L anguage
Designed by Dennis Ritchie (1972) C Programming used for developing UNIX OS L3Lecture 3 : C Introduction C features Dennis Ritchie Structured ppgrogrammin g,g , modular pgprogrammin g Highly portable Efficient (fast) C has the features of high level language and low level language
1 2 Lecture notes : courtesy of Woo Kyun and Chang Byung-Mo silimple C(hll)C program (hello.c) CilC compiler
compiler? Programmer can use high level language such as C CPU knows machine language (assembly language)
C program MhiMachine Compiler language int main… 010101…
output: C compiler Commercial compiler: Microsoft Visual C/C++ (ver. 6.0) Hello, World ! Free compiler: gcc
3 4 Visual Stu dio 6. 0 PDltProgram Development
Microsoft Visual C++ 6.0 Project window 1. Creating Project Editing window 2. Message window Adding Files 3. Editing Program 4. Compile&Build 5. Execution&Debugging
5 6
CtiPjt(1/5)Creating a Project (1/5) CtiPjt(2/5)Creating a Project (2/5)
1. File New 1. File New Projects tab 2. LtiLocation Win32 Console Application Folder selection 2. Location 3. Project Name 3. Project Name 4. OK 4. OK 5. Finish & OK 5. Finish & OK
7 8 CtiPjt(3/5)Creating a Project (3/5) CtiPjt(4/5)Creating a Project (4/5)
1. File New 1. File New 2. LtiLocation Win32 Consol e AAppli lica tion 3. Project Name 2. Location Hello 3. Project Name 4. OK 4. OK 5. Finish & OK 5. Finish & OK
9 10
CtiPjt(5/5)Creating a Project (5/5) Adding Fil es (1/3)
Hello project is created 1. File New Files ta b C++ Source File 2. filename 3. OK
11 12 Adding Fil es (2/3) Adding Fil es (3/3)
1. File New Source file hello.c is added to Hello project 2. filename Add to ppjroject hello.c 3. OK
13 14
Visual Studio 2 008 : File Edit Creating Command-Line Program
15 Visual Studio 2 008 Visual Studio 2 008 Creating Command-Line Program Creating Command-Line Program
Visual Studio 2 008 Visual Studio 2 008 Creating Command-Line Program Creating Command-Line Program Cil&BildCompile & Build CilCompile-time error
compile Compile hello.c Grammar error. Object file can not be created Double click error message line
Object fil e (.o bj) itdis created Build Build Hello.exe
Link : link object files and create a executable file (.exe)
21 22
PiPProgramming Process gcc /++/ g++
Source files (.c) Free C/C++ compiler developed by GNU
preprocessor
temporary program texts
compiler
Object files library files linker
Executable file (.exe)
23 24