Presentation is loading. Please wait.

Presentation is loading. Please wait.

Arguments to the main Function and Final Project

Similar presentations


Presentation on theme: "Arguments to the main Function and Final Project"— Presentation transcript:

1 Arguments to the main Function and Final Project
Speaker: Yao-Ting Huang Advisor: Kun-Mao Chao National Taiwan University Department of Computer Science & Information Engineering Algorithms and Computational Biology Lab. 2019/6/4

2 Arguments to main Function (1/2)
We may often need to pass arguments to the program upon execution. e.g., In DOS mode, you can type “copy file1.txt file2.txt” to copy a file. Syntax: int main(int argc, char *argv[]) argc: the number of arguments argv: an char array of arguments int main(int argc, char* argv[]){ fprintf(“%d\t”, argc); fprintf(“%s\t”, argv[0]); fprintf(“%s\n”, argv[1]); }

3 Arguments to main Function (2/2)
Suppose this program is compiled as “run.exe” Open the DOS command window. 開始選單->執行->cmd Change to the directory where “run.exe” exists. Type “run Hello” Output is “2 run Hello” Type “run Parameter1 Parameter2” Output is “3 run Parameter1”

4 Final Project You have to join a group composed of 5 to 7 people.
Important dates: Each group should turn in the list of members by 11/25. Each group should submit your proposal for final project by 12/2. In addition, each group should present your proposal at that day. TAs will check the progress of each group at 12/16. Each group should demo the prototype of your project. The final project is due on 12/30. Each group should demo your project and turn in a project report.

5 Example of A Project Project name: 大樂透開獎預測系統
Project member: 小趙(d1234) 、小莊(d1122) 、小黃(d7788)、小玉(b5678)、小小(b5566) System Functionalities: 可查詢歷次大樂透開獎號碼 可查詢某一特定號碼之開獎次數 可預測下一期某一號碼中獎機率 可判斷下一期某一組合號碼中獎機率 可預測下一期最佳開獎號碼組合 可預測何種包牌組合投資報酬率最高 模擬下一期大樂透開獎結果

6 Example of A Project 分工情形 程式技巧 小趙負責 小莊負責 查詢歷次大樂透開獎號碼 查詢某一特定號碼之開獎次數 …
需使用檔案IO處理函示 (例如、fprintf與fscanf) 紀錄與查詢歷次大樂透開獎結果

7 Homework #5 (1/2) Write a program that computes the average grades and sorts the grades of two classes. Your program should input two lists of grades for each class. Your program should output: (1) average grades for each class, and (2) a list of sorted grades of two classes. You can either assume the number of students in each class is fixed or prompt the user to input the number. You can use the sorting function in p.401 in the text book.

8 Homework #5 (2/2) e.g., Please input grades of the 1st class: Please input grades of the 2nd class: Output: The average grades of 1st class is: 65 The average grades of 2nd class is: 60 The sorted grades of two classes are: Due date: 11/25.

9 Outline of Lecture Today
A C file program with arguments to main function. Demo of your Homework #4. Please make sure your program is ready to execute.


Download ppt "Arguments to the main Function and Final Project"

Similar presentations


Ads by Google