投影片 1

Similar documents
第 15 章 程 式 編 写 語 言 15.1 程 式 編 写 語 言 的 角 色 程 式 編 寫 語 言 是 程 式 編 寫 員 與 電 腦 溝 通 的 界 面 語 法 是 一 組 規 則 讓 程 式 編 寫 員 將 字 詞 集 合 起 來 電 腦 是 處 理 位 元 和 字 節 的 機 器, 與

2/80 2

CC213

epub83-1

untitled

<4D F736F F F696E74202D20C8EDBCFEBCDCB9B9CAA6D1D0D0DEBDB2D7F92E707074>

Microsoft Word - PS2_linux_guide_cn.doc

Oracle Solaris Studio makefile C C++ Fortran IDE Solaris Linux C/C++/Fortran IDE "Project Properties" IDE makefile 1.

ebook140-9

untitled

ebook8-30

热设计网

ebook140-8

目次 

Windows XP

1 LINUX IDE Emacs gcc gdb Emacs + gcc + gdb IDE Emacs IDE C Emacs Emacs IDE ICE Integrated Computing Environment Emacs Unix Linux Emacs Emacs Emacs Un

Learning Java

Oracle Oracle Solaris Studio IDE makefile C C++ Fortran makefile IDE Solaris Linux C/C++/Fortran Oracle IDE "P

錄...1 說...2 說 說...5 六 率 POST PAY PREPAY DEPOSIT 更

投影片 1

AL-M200 Series

1.ai

2 2 3 DLight CPU I/O DLight Oracle Solaris (DTrace) C/C++ Solaris DLight DTrace DLight DLight DLight C C++ Fortran CPU I/O DLight AM

Microsoft Word - 11.doc

EK-STM32F

CH01.indd

Guide to Install SATA Hard Disks

言1.PDF

IP TCP/IP PC OS µclinux MPEG4 Blackfin DSP MPEG4 IP UDP Winsock I/O DirectShow Filter DirectShow MPEG4 µclinux TCP/IP IP COM, DirectShow I

<4D F736F F D205F FB942A5CEA668B443C5E9BB73A740B5D8A4E5B8C9A552B1D0A7F75FA6BFB1A4ACFC2E646F63>

128 ( ) ( ) [ 1 ] [2] [3] (1) (2) (3) [1] [2] [3] 10 2 ( ) (1997.6) ( ) 64

投影片 1

简 介 本 白 皮 书 高 度 概 述 了 支 持 移 动 互 联 网 设 备 (Mobile Internet Device) 的 Intel C++ Software Development Tool Suite for Linux* OS, 目 标 读 者 主 要 是 技 术 决 策 制 订

untitled

WinMDI 28

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

PowerPoint 演示文稿

C/C++程序设计 - 字符串与格式化输入/输出

Java 1 Java String Date

Microsoft Word - linux命令及建议.doc

Logitech Wireless Combo MK45 English

C C C The Most Beautiful Language and Most Dangerous Language in the Programming World! C 2 C C C 4 C Project 30 C Project 3 60 Project 40

國立中山大學學位論文典藏.PDF

mvc

RUN_PC連載_12_.doc

Microsoft Word - template.doc

untitled

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile..

C++ 程式設計

Microsoft Word htm

声 明 本 人 郑 重 声 明 : 此 处 所 提 交 的 硕 士 学 位 论 文 基 于 等 级 工 鉴 定 的 远 程 考 试 系 统 客 户 端 开 发 与 实 现, 是 本 人 在 中 国 科 学 技 术 大 学 攻 读 硕 士 学 位 期 间, 在 导 师 指 导 下 进 行 的 研 究

Microsoft Word - A _ doc

本文由筱驀釹贡献

Some experiences in working with Madagascar: installa7on & development Tengfei Wang, Peng Zou Tongji university

WTO

(Pattern Recognition) 1 1. CCD

软件测试(TA07)第一学期考试

Improved Preimage Attacks on AES-like Hash Functions: Applications to Whirlpool and Grøstl

NEXT SDT2.51 C:\ARM251 SDT2.51 ARM SDT 2.51 ARM PROJECT MANAGER SDT 2

PowerPoint Presentation

A9RF716.tmp

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

sp_overview.pptx

软件自由法律中心 GPL 软件许可证合规指导

VB程序设计教程

A Preliminary Implementation of Linux Kernel Virus and Process Hiding

第零章、為何要學作業系統

untitled

Microsoft Word doc

ARM JTAG实时仿真器安装使用指南

TX-NR3030_BAS_Cs_ indd

Microsoft PowerPoint - STU_EC_Ch08.ppt

C/C++ - 文件IO

Microsoft Word - CX VMCO 3 easy step v1.doc

Microsoft Word _2 課本1225_OK_0222修.doc

1 C++ 2 Bjarne Stroustrup C++ (system programming) 6 (infrastructure) C++ 7 Herb Sutter 8 C++ (efficiency) (flexibility) 9 (abstraction) (productivity

K7VT2_QIG_v3

untitled

Cygwin & vim

Microsoft Word - 把时间当作朋友(2011第3版)3.0.b.06.doc

AN INTRODUCTION TO PHYSICAL COMPUTING USING ARDUINO, GRASSHOPPER, AND FIREFLY (CHINESE EDITION ) INTERACTIVE PROTOTYPING

Microsoft PowerPoint - ch6 [相容模式]

ebook35-2

Chn 116 Neh.d.01.nis

國立臺灣藝術大學

2/14 Buffer I12, /* x=2, buffer = I 1 2 */ Buffer I243, /* x=34, buffer = I 2 43 */ x=56, buffer = I243 Buffer I243I265 code_int(int x, char *buffer)

IP505SM_manual_cn.doc

ebook70-5

untitled

高 职 计 算 机 类 优 秀 教 材 书 目 * 序 号 书 号 (ISBN) 书 名 作 者 定 价 出 版 / 印 刷 日 期 ** 配 套 资 源 页 码 计 算 机 基 础 课 计 算 机 应 用 基 础 刘 升 贵 年 8 月

lect03.ppt

1. 請 先 檢 查 包 裝 內 容 物 AC750 多 模 式 無 線 分 享 器 安 裝 指 南 安 裝 指 南 CD 光 碟 BR-6208AC 電 源 供 應 器 網 路 線 2. 將 設 備 接 上 電 源, 即 可 使 用 智 慧 型 無 線 裝 置 進 行 設 定 A. 接 上 電 源

投影片 1

Microsoft Word - 专论综述1.doc

HOL-CHG-1695

1 SQL Server 2005 SQL Server Microsoft Windows Server 2003NTFS NTFS SQL Server 2000 Randy Dyess DBA SQL Server SQL Server DBA SQL Server SQL Se

The Development of Color Constancy and Calibration System

南華大學數位論文

大学计算机基础B.doc

untitled

Transcription:

Chapter 1: Start C-Language How To Speaker: Lung-Sheng Chien

OutLine Course skeleton Introduction of programming language How to use Visual C++ MSDN library Linux machine

Schedule: July : http://www.oz.nthu.edu.tw/~d947207/ 六 1 2 3 chapter 1 4 Chapter 2 5 Chapter 3 6 7 8 9 10 11 12 Chapter 4 Chapter 5 Chapter 6 Chapter 7 vim 13 14 數 15 數 16 數 17 數 18 數 19 數 20 數 21 數 22 數 23 數 24 25 26 27 28 29 30 31 Chapter 8 Chapter 9 Chapter 10

Workstations we have IP OS cpu memory 140.114.34.1 R705 Fedora 7 64-bit 140.114.34.11 R705 Fedora 7 64-bit 140.114.34.12 R705 Fedora 7 64-bit 140.114.34.13 R705 Fedora 7 64-bit 140.114.34.201 R705 RedHat 9 32-bit 140.114.34.214 R705 RedHat 9 32-bit 140.114.34.216 R705 RedHat 9 32-bit Intel(R) Xeon(R) CPU X5365 @ 3.00GHz, 2 cpu Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz Intel(R) XEON(TM) CPU 2.20GHz, 2 cpu Intel(R) Pentium(R) 4 CPU 3.00GHz Intel(R) Pentium(R) 4 CPU 3.00GHz 64 GB 8 GB 8 GB 8 GB 4 GB 2 GB 2 GB

Platform and resource platform Linux Windows compiler gcc, g++ icpc (Intel C compiler) vc 6.0 (Microsoft Visual Studio) editor vi vc IDE interface C++ document? MSDN Library 2008 GUI support Qt Qt Makefile generator qmake qmake + vc

R705 ( ) floorplanning 32-64 - 理 115 114 113 117 118 119 122 121 120 IP 140.114.34.117 ~119 are experimental computers in this course

Software list in experimental computer software description Visual studio 6.0 MSDN library 2008 Write C/C++ source code, compile and link C++ document Qt library ssh secure shell GUI programming and Makefile generator login workstations, it use MD5-encryption for connection

What we must learn C- basic skill Data structure stack, queue, tree Expression/loop analysis Networking FSM (Finite state machine) Regular expression Matrix class C++ (under Qt) 2D image Multithread technique 3D graphic Parallel computing Out-of-core programming

Topics in C-language Structure, including stack, queue, tree I/O, including Terminal, File Operators, function C- basic skill Pointer, array Primitive data type Control flow TextBook: The C Programming Language, Kernighan

Delivery after this course MATLAB (interpreter), symbolic toolbox 2-Elevators system Out-of-core programming 2D image (image processing), GIS, GRASS 3D graphic (mesh generator), finite element Maze ( 老 ) Prime number Compiler issue, debugger Issue about economy

OutLine Course skeleton Introduction of programming language How to use Visual C++ MSDN Library Linux machine

Sorts of Programming Language High-level language (C, C++, Java, Fortran, Verilog, VHDL, COBOL, ), independent of Machine Low-level language, assembly, depends on machine s architecture. Machine code, can be executed in cpu.of course it depends on machine architecture.

Why not Assembly or Machine code? awkward ( ) and low readability Operation is atomic, we need more abstract-like programming style Performance is Human-tuning, timeconsuming

Hierarchical view of Language High-level Language (C, C++, Fortran) Language translator High-level Language decompiler Compiler Assembly f2c : fortran to C is a language translator deassembler Assembler Machine code

C++ compiler we will use Compiler Author Windows Linux gcc, g++ GNU yes, with Cygwin yes Intel C++ Intel yes yes Visual Studio Microsoft yes no

Phases of a Compiler Source code Lexical analyzer Syntax analyzer ( ) We will cover this technique FSM Semantic analyzer ( ) Intermediate code generator Code optimizer Code generator machine code

Role of Compiler Shorten cycle of development - find the bugs - help programmers to write efficient and economic codes (relate to what language you use) Optimization, speed, low-power, Code generation

Standard of C/C++ ANSI C is current C-language standard, proposed by ANSI (American National Standard Institute ) Microsoft visual C has additional keywords not in C-standard, however this is o.k. if we write C codes under standard rule.

OutLine Course skeleton Introduction of programming language How to use Visual C++ - write Hello World program MSDN library Linux machine

Why visual studio (microsoft) IDE (Integrated Development Environment) Code editor Project management Debugger : weapon for learning C-language

Visual Studio IDE Microsoft Visual Studio 6.0 Microsoft Visual C++ 6.0

Step 1: (new project) [File] [New]

Step 2: console ( ) 2. helloworld 1. Win32 console 3. 料

Step 3: ( ) 1. 2. 靈

FileView Click FileView, no files are in this project. In directory helloworld, only project related files exist.

Step 4: [project] [Add to Project] [New] new

C++ main.cpp 1. C++ 2. main,cpp

Source Files 錄 main.cpp 1. 滑 main.cpp 2.

Step 5: 2. 1. Key in Text window

Step 6: Compilation ( ) : translate source code to object code 1. [Build] [Compile main.cpp] 2.

Step 7: Build (Linking phase, ) : combine object code into a executable file 1. [Build] [Build helloworld.exe] 2. Link message

Step 8: Execution ( 行 helloworld.exe) 1. [Build] [Execute helloworld.exe] 2. 行

What we have done! 行 Object code by compilation main.cpp

Source code s interpretation comments A compiler regards characters between /* and */ as comments and ignores them. Include information about standard library Std: standard, io: Input/Output Function body main is a function with 2 arguments and return integer (int) main calls library function printf to print string constant Hello world into screen return 0 corresponds to return type int of main

Key sentences 數 數 (argument) 數 (prototype) 參數 (parameter) 數 0 數 printf 數 (definition)

Purpose of #include <stdio.h> When compiler read printf("hello World\n");, it would recognize it is a function with function name printf, then compiler would do type checking, say one must declare prototype of function printf first such that compiler can do type checking. Example: comment #include <stdio.h>, then compile again, error occurs

錄 C:\Program Files\Microsoft Visual Studio\VC98\Include stdio.h 1. stdio.h, 滑 2. stdio.h, 滑, Visual Studio

[Edit] [Find] printf Find Next 3. 2. printf 1. Find stdio.h

Find prototype of printf in file stdio.h Not printf, F3 This is prototype of function printf printf("hello World\n"); Hello World 串, type checking int printf(const char *,...); 串

Declare prototype of printf before using it File stdio.h is not included 1. Declare prototype of printf 2. Call function printf Keywords, ifdef, extern, cplusplus, are explained later

Error: use printf before declaring its prototype, why? Compiler does not see any prototype

Why function main has no prototype? main is an entry point of program, it is unique, say only one main can appear. main has the definition, which is enclosed by a pair of brace. Declare prototype of function main Definition of main

Mismatch between prototype and definition Prototype of main Definition of main Overloaded is a C++ keyword, we will interpret later

OutLine Course skeleton Introduction of programming language How to use Visual C++ MSDN library Linux machine

MSDN Library MicroSoft Developer Network Includes sample code, technical articles, and C/C++ standard description It is free, you can download it from microsoft s download center

MSDN Library Microsoft Developer Network MSDN Library 1. MSDN Library 2. MSDN Library

printf [1] 1. search 2. printf enter 4. 3.

printf [2] Example code, you can copy it and test it Prototype of printf

OutLine Course skeleton Introduction of programming language How to use Visual C++ MSDN library Linux machine - use ssh to login remote machine - commands in Linux machine - How to compile

ssh (MD5 ) SSH Secure Shell Secure Shell Client

立 連 [1] Quick Connet

立 連 [2] 1. IP 3. Connect 紐 2.

立 連 [3]

立 連 [4] 1. imsl linux 錄 imsl

Commands in common use command passwd pwd ls cd mkdir rm top cat /proc/cpuinfo cat /proc/meminfo uname -a man icc, icpc gcc, g++ which Description Change password Current working directory List all files and subdirectory in current directory Change directory Make a new directory Remove a file/directory Show process information Show cpu s information Show memory s information Show machine s information Look up manual of commands Intel C/C++ compiler GNU C/C++ compiler Show full path of commands

uname -a linux.am.nthu.edu.tw : domain name 2.4.20-8smp : RedHat9 I686: 32, x86_64: 64

cat /proc/cpuinfo 1. CPU Pentium 4 2. Actual running clock rate

cat /proc/meminfo 2GB 2GB

top 2GB 2GB

pwd and ls 1. 錄 2. 列 錄 3. 4. pwd

mkdir 1. 錄 course

cd 1. 錄 course 2. 錄 3. 錄 course 2. cd.. 離 錄, 錄

Compiler icpc, gcc

which 1. Full path of command icpc 2. Full path of gcc 3. icpc 錄 4. icpc 錄

sftp [1] 1. sftp sftp (secure ftp) window 2. 錄 course

sftp [2] 滑 錄 helloworld

sftp [3]

[1] 1. 錄 course 2. 錄 helloworld 3. main.cpp 行 a.out 4. 行 a.out

[2] 1. a.out 3. a.out 2. g++ 4. 行

passwd : 1., entrer 2., enter 3., enter