C Program Design Supplements 主講人:虞台文. Content Who takes the return value of main() ?

Slides:



Advertisements
Similar presentations
FCU, Department of ECE, IC Design Research Lab. TEL: # 4945 Pre-SIm , Post-Sim.
Advertisements

1 生物計算期末作業 暨南大學資訊工程系 2003/05/13. 2 compare f1 f2  只比較兩個檔案 f1 與 f2 ,比完後將結果輸出。 compare directory  以兩兩比對的方式,比對一個目錄下所有檔案的相 似程度。  將相似度很高的檔案做成報表輸出,報表中至少要.
學習C++的基本語法 認識關鍵字與識別字的不同 學習程式碼偵錯的流程 學習如何提高程式的可讀性
I/O FUNCTIONS 輸入 與 輸出. #include int fclose(FILE *); int feof(FILE *); int fflush(FILE *); int fgetc(FILE *); getchar(); char *fgets(char*, int, FILE*);
MultiCore ATPG 2010 IC/CAD Contest 組員:林中正、曾國賢. Goal.
Lab2 Tutorial CS340100, Lab2 Brief Introduction 學習重點 – 如何實作 FilterInputStream, FilterOutputStream – 使用 Java IO (ex: 存取檔案 ) 工作項目 – 實作 EndianTranslationInputStream.
SIP Mobiity TA: 洪敏書
: Boxes ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11003: Boxes 解題者:蔡欣燁 解題日期: 2007 年 3 月 19 日.
五小專案 黃詩晴 章乃云. 目錄 計算機 智慧盤 拼圖 記憶大挑戰 數學題庫 心得 參考文獻.
嵌入式系統概論 - 以 S3C2440 核心為架構 CH16 、第一個 Linux 程式設計. 嵌入式系統概論 - 以 S3C2440 核心為架構 許永和 大綱  16.1 撰寫第一個 Linux 程式  16.2 利用 minicom 與開發平台做溝通  16.3 利用.
第一章 變數、常數及資料型態. 變數 C 程式語言的變數名稱 第一個字必須是英文字母或底線 (_) 之後可以是數字, 英文字母或底線 (_) 不可以是保留字 例: Num (Ο) _score (Ο) C&C (X) 8num (X)
: Problem E - Beverages ★★★☆☆ 題組: Contest Archive with Online Judge 題號: 11060: Problem E - Beverages 解題者:李重儀 解題日期: 2008 年 3 月 4 日 題意: Dilbert 大學剛畢業,他決定要和朋友出去。他有奇怪的嗜好,
1.1 電腦的特性 電腦能夠快速處理資料:電腦可在一秒內處理數百萬個 基本運算,這是人腦所不能做到的。原本人腦一天的工 作量,交給電腦可能僅需幾分鐘的時間就處理完畢。 電腦能夠快速處理資料:電腦可在一秒內處理數百萬個 基本運算,這是人腦所不能做到的。原本人腦一天的工 作量,交給電腦可能僅需幾分鐘的時間就處理完畢。
McGraw-Hill/Irwin © 2003 The McGraw-Hill Companies, Inc.,All Rights Reserved. 肆 資料分析與表達.
MS-DOS 作業系統 張基昇 (Microsoft-Disk Operating System).
程式語言實習 - JAVA Class1 1. 介紹 Java 編寫、編譯、執行 2. 請同學完成作業二.
Web Meeting 使用教學 ─ 學生版.  如何即時線上與老師互動? 一. 瀏覽太御科技首頁 二. 安裝 JoinNet 在首頁的左手邊 1. 下載 JoinNet 進行安裝 JoinNet.
程式註解說明. 2 程式註解格式 塊狀註解 對檔案、 class 、 method 、資料結構、一段程式 …. 等程式區塊 做說明。 第一行的開頭必需為 “/*” 且沒有其他文字,最後一行的開頭 必需以 “*/” 做為結束,在中間每一行的開頭都必需是一個 “*” 。 單行註解 佔據一整行的說明。 以.
1 網路同步學習 如何使用中山大學管理學院知識管理平台 愷中 製作. 2 如何登入中山大學網路學習平台 1. 首先, 請輸入 2. 點選申請帳號, 依照螢幕所示, 輸入個人資訊.
資料處理 汪群超 2 這一年將學習到什麼? 網際網路:你在哪裡?瞭解你的角色、駕馭網路 。 Web 、 FTP 、 、 Proxy 、 Database Servers 記錄你的學習歷程、展現學習成果: Homepage 、 PowerPoint.
IR 組員 : 資工 4A 王俊傑 資工 4B 陳國富 資工 4B 夏希璿.
軟體保護技術及其弱點 序列號保護與弱點. 組員名單 資訊三乙 D 吳俊緯 資訊三乙 D 吳俊緯 資訊三乙 D 陳品端 資訊三乙 D 陳品端.
第 5 章 深入 Response 物件 製作. 網頁的轉向與強制輸出 - 讓網頁轉彎的 Redirect 敘述 運用 Response 物件的 Redirect 方法,將瀏覽器顯 示的網頁,導向至其他網頁,語法如下: Response.Redirect 網頁路徑與名稱 此網頁路徑與名稱  若是導向到同一台.
3 levels 6 modules 9 speakers 18 tutorials 27 video clips 36 skill consolidation 135 activities/test 162 mark up/records 300 hours Speech recognition Connected.
24-6 設定開始與結束場景中的 程式 最後我們要替這個遊戲收個尾, 幫它把開始 的等待畫面跟結束畫面處理一下。
最新計算機概論 第 5 章 系統程式. 5-1 系統程式的類型 作業系統 (OS) : 介於電腦硬體與 應用軟體之間的 程式,除了提供 執行應用軟體的 環境,還負責分 配系統資源。
吳季恆 張書瑋. 摘要 現今許多 IC 設計公司所使用的 multi-supply voltage island(MSV) 和 power gating (PSO) 低功耗設計技 術,即是將晶片上的各個 block 分為 power-on 以及 其他可關閉之 power.
: Fast and Easy Data Compressor ★★☆☆☆ 題組: Problem Set Archive with Online Judge 題號: 10043: Fast and Easy Data Compressor 解題者:葉貫中 解題日期: 2007 年 3.
各種線上電子資源的特異功能 SwetsWise 的 alert, TOC alert 與 Favorites 2003/4/28 修改.
行政院國家科學委員會工程技術發展處自動化學門 * 試以國立成功大學製造工程研究所 鄭芳田教授 產學合作計畫 : 智慧預測保養系統之設計與實作 成果報告盤點為範例 國科會工程處專題計畫成果典藏 自動化學門成果報告盤點範例.
國立聯合大學 資訊管理學系 陳士杰老師 SQL*Plus 與 iSQL*Plus 簡介. 國立聯合大學 資訊管理學系 資料庫系統課程 ( 陳士杰 ) 2 啟動 SQL*Plus 與 iSQL*Plus 方式 Windows 平台.
校外使用圖書館購置之資料庫 龍華大學圖書館. 讀者遠端認證 (RPA) 設定說明  透過圖書館架設完成的 RPA (Remote Patron Authentication) 讀者遠端認證代理主 機系統,讀者於校外或院外 可直接連線使 用本館所提供的資料庫。  若非使用本館電子資料,請勿設定此代理.
卡內基訓練  Copyright, 1997 © Dale Carnegie & Associates, Inc. 1 簡報標題 TIP 如需進一步建議, 請看卡內基訓練  的簡報技巧.
從此處輸入帳號密碼登入到管理頁面. 點選進到檔案管理 點選「上傳檔案」上傳資料 點選瀏覽選擇電腦裡的檔案 可選擇公開或不公開 為平台上的資料夾 此處為檔案分類,可顯示在展示頁面上,若要參加 MY EG 競賽,做品一律上傳到 “ 98 MY EG Contest ” 點選此處確定上傳檔案.
資料結構實習-一 參數傳遞.
企二 A 管理程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 企二 A 管理程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷
Hung-Hsiang WuWindows Processing Design1 Chapter 4 簡單視窗程式 表單與標籤的屬性 按鈕與編輯的屬性 設計簡單的應用程式 表單常用事件 一般鍵盤及滑鼠常見的事件 表單視窗間的呼叫 表單間資料傳送應用 專案選擇設定.
4 堆疊與佇列 4.1 前言 四種基本的資料結構 (可儲存資料的容器) 陣列 (Array)、串列(List): 最基本
Management Abstracts Retrieval System; MARS 檢索操作.
函式 Function Part.2 東海大學物理系‧資訊教育 施奇廷. 遞迴( Recursion ) 函式可以「呼叫自己」,這種動作稱為 「遞迴」 此程式的執行結果相當於陷入無窮迴圈, 無法停止(只能按 Ctrl-C ) 這給我們一個暗示:函式的遞迴呼叫可以 達到部分迴圈的效果.
資料結構實習-二.
: Expect the Expected ★★★★☆ 題組: Contest Archive with Online Judge 題號: 11427: Expect the Expected 解題者:李重儀 解題日期: 2008 年 9 月 21 日 題意:玩一種遊戲 (a game.
File I/O 範例講解 授課:林哲嘉 日期: 2009/04/29. 範例:上機考第三題 Add 部分 1. 將檔案的資料顯示在畫面 2. 將要加入檔案加到資料的尾端.
資料結構實習-十 Binary Tree Traversal.
: Function Overloading ★★★☆☆ 題組: Problem Set Archive with Online Judge 題號: 11032:Function Overloading 解題者:許智祺 解題日期: 2007 年 5 月 8 日 題意:判對輸入之數字是否為.
概念性產品企劃書 呂學儒 李政翰.
無線通訊網路 Mac 層 TDM 通訊模式的操作與效能研究 專題生 : 林書弘、蔡逸祥、毛建翔、王政 華 指導教授 : 黃依賢.
組合語言與系統程式 軟體使用教學. 軟體下載及安裝 下載 到課程網頁下載 tw/~jiun/ 安裝 解壓縮後將 System Software 資料夾放在 D 槽 (C 槽版本放在 C 之下 )
第十一章 分析法. 2  分析法 (analysis method) 是以分析的方式來解 決,亦即把問題細分成其組成部分,以便發現其 真實特性以及各變數間的因果關係.
Biological Science Database 個人化服務設定步驟. Biological Science Database 僅提供專題選 粹服務 專題選粹 (Alerts) :查詢後,提供儲存檢 索策略的功能,日後每週將符合條件的 更新資料,採 方式通知。每筆設定 最多每週可收到.
2 C++ 程式概論 2.1 C++ 程式結構 程式註解 // 插入標題檔 #include 2-3
3 數學運算 3.1 鍵盤輸入 鍵盤輸入 輸入函數 cin 輸入函數 cin 多重輸入 cin 多重輸入 cin 輸出格式化 輸出格式化 設定輸出長度 setw.
INFORMATION RETRIEVAL AND EXTRACTION 作業: Program 1 第十四組 組員:林永峰、洪承雄、謝宗憲.
1 EndNote 金珊資訊有限公司 2 EndNote X2 新功能 新增標籤 (Tab) 視窗 線上查詢群組 智慧群組 (Smart Groups) 新增參考文獻類型 查詢全文 標示日期 以電子郵件傳送壓縮的 Library 檔案 Library.
如何使用 Yahoo Messenger Yahoo Messenger 雅虎即時通 讓你在第一時間內和上線的朋 友溝通!
論文閱讀報告 論文題目:應用模糊理論於颱風降雨量之推估 作者:陳正彬. 模糊化類神經網路 ‧模糊系統的建立 1. 由人類專家建立規則 ex:if 風速大 then 降雨量高 效果受到規則庫完整的影響 2. 經由訓練法則從數值資料得到模糊規則.
-Artificial Neural Network- Matlab操作介紹 -以類神經網路BPN Model為例
Visual C++重點複習.
1 Introduction to Java Programming Lecture 3 Mathematical Operators Spring 2008.
C 語言練習題 2010/12/2. C 程式的格式 一、 C 程式的格式 (1). /* …. */ 是 C 程式的 ______ main() 的內容是由敘述構成的 (2). 敘述要以 __ 為結束符號 (3). 變數、函數都要做 ____ 的宣告 (4). ‘=’ 是 ____ 用的算符 (5).
第十三章 檔案. 檔案 I/O 的基本觀念 檔案 I/O 的流程 定義指向 FILE 結構的指標 開啟一檔案 呼叫檔案 I/O 庫存函數以進行檔案的處理 關閉檔案 FILE 結構 此結構宣告於 標頭檔中.
著作權所有 © 旗標出版股份有限公司 第 14 章 製作信封、標籤. 本章提要 製作單一信封 製作單一郵寄標籤.
6 使用者函數 6.1 函數定義 宣告函數 呼叫函數 呼叫多個函數 6-6
1 Introduction to Java Programming Lecture 3 Mathematical Operators Spring 2009.
遠端北風資料庫 公佈時間: 2006/4/26 繳交截止時間: 2006/5/10. 作業目的 實作遠端資料庫瀏覽程式.
Introduction to C Language ─ C 語言的基本概念. 大綱 C 編譯器簡介 Turbo C++ 的安裝與操作介紹 如何編寫 C 語言程式 輸出與輸入函數 Homework 資料參考網站.
Chapter 4 Functions and Program Structure Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering.
C Program Design Supplements 主講人:虞台文. Content Who takes the return value of main() ? Using Command-Line arguments Variable-Length Argument Lists Program.
Engineering Computing I Chapter 4 Functions and Program Structure.
Programming Language  C Functions and Program Structure 主講人:虞台文.
Presentation transcript:

C Program Design Supplements 主講人:虞台文

Content Who takes the return value of main() ?

C Program Design Supplements Who takes the return value of main() ?

main() int main( void ) { /* declaration of variable */ /* operations */ return result; /* who takes the result? */ } int main( void ) { /* declaration of variable */ /* operations */ return result; /* who takes the result? */ }

Example: Unix grep Ah Love! could you and I with Fate conspire To grasp this sorry Scheme of Things entire, Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire! Ah Love! could you and I with Fate conspire To grasp this sorry Scheme of Things entire, Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire! grepExample.txt Ah Love! could you and I with Fate conspire To grasp this sorry Scheme of Things entire, Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire! Ah Love! could you and I with Fate conspire To grasp this sorry Scheme of Things entire, Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire! grep "ould" grepExample.txt Ah Love! could you and I with Fate conspire Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire! Ah Love! could you and I with Fate conspire Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire!

Example: Unix grep Ah Love! could you and I with Fate conspire To grasp this sorry Scheme of Things entire, Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire! Ah Love! could you and I with Fate conspire To grasp this sorry Scheme of Things entire, Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire! grepExample.txt Ah Love! could you and I with Fate conspire To grasp this sorry Scheme of Things entire, Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire! Ah Love! could you and I with Fate conspire To grasp this sorry Scheme of Things entire, Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire! grep "ould" grepExample.txt Ah Love! could you and I with Fate conspire Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire! Ah Love! could you and I with Fate conspire Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire!

Pseudo Code  The Idea to Fulfill the Task count = 0; while (there's another line) if (the line contains the pattern) print it count++; return count;

Pseudo Code  The Idea to Fulfill the Task count = 0; while (there's another line) if (the line contains the pattern) print it count++; return count; How? Define functions to mind the detail. How? Define functions to mind the detail.

Pseudo Code  The Idea to Fulfill the Task count = 0; while (there's another line) if (the line contains the pattern) print it count++; return count; Pseudo Code  The Idea to Fulfill the Task int getline(char line[], int max) int strindex(char source[], char searchfor[])

Example: MyGrep #include #define MAXLINE 1000 /* maximum input line length */ int getline(char line[], int max); int strindex(char source[], char searchfor[]); char pattern[] = "ould"; /* pattern to search for */ /* find all lines matching pattern */ int main( void ) { char line[MAXLINE]; int count = 0; while (getline(line, MAXLINE) > 0) if (strindex(line, pattern) >= 0) { printf("%s", line); count++; } return count; } #include <stdio.h> #define MAXLINE 1000 /* maximum input line length */ int getline(char line[], int max); int strindex(char source[], char searchfor[]); char pattern[] = "ould"; /* pattern to search for */ /* find all lines matching pattern */ int main( void ) { char line[MAXLINE]; int count = 0; while (getline(line, MAXLINE) > 0) if (strindex(line, pattern) >= 0) { printf("%s", line); count++; } return count; } return information to OS

Example: MyGrep #include #define MAXLINE 1000 /* maximum input line length */ int getline(char line[], int max); int strindex(char source[], char searchfor[]); char pattern[] = "ould"; /* pattern to search for */ /* find all lines matching pattern */ main() { char line[MAXLINE]; int count = 0; while (getline(line, MAXLINE) > 0) if (strindex(line, pattern) >= 0) { printf("%s", line); found++; } return count; } #include <stdio.h> #define MAXLINE 1000 /* maximum input line length */ int getline(char line[], int max); int strindex(char source[], char searchfor[]); char pattern[] = "ould"; /* pattern to search for */ /* find all lines matching pattern */ main() { char line[MAXLINE]; int count = 0; while (getline(line, MAXLINE) > 0) if (strindex(line, pattern) >= 0) { printf("%s", line); found++; } return count; } while (there's another line) if (the line contains the pattern) print it forward references return information to OS

Batch Files

Example: MyGrep Ah Love! could you and I with Fate conspire To grasp this sorry Scheme of Things entire, Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire! Ah Love! could you and I with Fate conspire To grasp this sorry Scheme of Things entire, Would not we shatter it to bits -- and then Re-mould it nearer to the Heart's Desire!

練習: 1. 完成以上程式,並測試之。 2. 撰寫一程式讀取使用者從標準輸入裝置中輸 入之字元直到發生 EOF 止,該程式會將所讀 取到的字元總數回傳給作業系統後結束執行。 3. 撰寫一批次檔驗證你能正確收到上題程式之 回傳資料,並做適當顯示。