Download presentation
Presentation is loading. Please wait.
1
Introduction to C Programming
HOMEWORK 6
2
Homework 6-1:字串輸入練習 說明 Sample input Content of input file
由使用者在執行程式的時候,指定檔案名稱,程式由使用者指定檔案讀入內容,將從檔案讀入的內容寫到字串當中,再把內容輸出到螢幕上 Sample input C:\Users\Peter\Desktop\test\bin\Debug\hw-6-1.exe input.txt Content of input file Sample output Read from: input.txt The content of file:
3
Homework 6-2:strtok練習 說明 Sample input Content of input file
由使用者在執行程式的時候,指定檔案名稱,程式由使用者指定檔案讀入內容,將從檔案讀入的內容寫到字串當中,再先把Domain Name和後面的參數切開存到靜態陣列。接下來再把後面的參數,利用「?」切出服務名、利用「&」切出參數,依序切開後存到靜態陣列,最後再將存在靜態陣列當中的每個參數的內容輸出到螢幕上(輸出格式請使用投影片Sample Output的格式),並寫出總共有幾個參數 Sample input C:\Users\Peter\Desktop\test\bin\Debug\hw-6-2.exe input.txt Content of input file
4
Homework 6-2:strtok練習 (續)
Sample output Domain Name: Service is “search” No.1 argument is “q=foo+bar” No.2 argument is “ie=utf-8” No.3 argument is “oe=utf-8” No. 4 argument is “aq=t” ============================== There are 4 arguments in this URL.
5
Homework 6-3:strcmp練習 說明
由使用者在執行程式的時候,指定檔案名稱,程式由使用者指定檔案讀入內容,將從檔案讀入的內容寫到字串當中,再先把Domain Name和後面的參數切開存到靜態陣列。接下來再把後面的參數,依序切開後存到靜態陣列,然後再利用strcmp去掃第一個字串,透過下面的服務列表,印出對應的服務名稱。
6
Homework 6-3:strcmp練習 字串名稱 服務名稱 search Web Search webhp imghp
Image Search maps Map and Street View nwshp News
7
Homework 6-3:strcmp練習(續)
Sample input C:\Users\Peter\Desktop\test\bin\Debug\hw-6-3.exe input.txt Content of input file Sample output No. 1 service is “Web Search”. No. 2 service is “Image Search”. No. 3 service is “Map and Street View”. No. 4 service is “News”. No. 5 service is unknown service.
8
Homework 6-4:字串上色 說明 Sample input Content of input file Sample output
由使用者在執行程式的時候,指定檔案名稱,程式由使用者指定檔案讀入內容,將從檔案讀入的內容寫到字串當中,在輸出到螢幕上的時候,將service用亮藍色上色輸出,將「?」、「&」等分界符號用亮紅色輸出,將參數用亮黃色輸出。 Sample input C:\Users\Peter\Desktop\test\bin\Debug\hw-6-4.exe input.txt Content of input file Sample output
9
Homework 6-4 Hint:色碼 參考資料:
10
Homework 6-4 Hint:色碼 輸出結果:
11
Homework 6-5:strstr練習 說明
由使用者在執行程式的時候,指定檔案名稱,程式由使用者指定檔案讀入內容,將從檔案讀入的內容寫到字串當中,再先把Domain Name和後面的參數切開存到靜態陣列。接下來再把後面的參數,利用「?」切出服務名、利用「&」切出參數,依序切開後存到靜態陣列,最後在從「q=keyword」參數當中,取出待找的keyword,然後再從待找檔案(database.txt)當中,去找出keyword所在,若有找到,列出找到keyword幾次、並印出第一個keyword出現的位置與其後面的15個字元。
12
Homework 6-5:strstr練習 Sample input Content of input file
C:\Users\Peter\Desktop\test\bin\Debug\hw-6-5.ext input.txt Content of input file
13
Homework 6-5:strstr練習 待找檔案(database.txt)的內容
In a typical hypervisor, there are three major compo- nents: CPU virtualization, memory virtualization, and I/O virtualization. For CPU virtualization, ARMvisor uses traditional “trap and emulate” to deal with sensi- tive instructions. Since there is no hardware support for virtualization in ARM architecture V6 and earlier, we have to patch the guest OS to force critical instructions to trap. For memory virtualization, the functional- ity of the MMU, which translates a guest virtual address to host physical address, is emulated. In ARMvisor, a shadow page table is dynamically allocated to avoid the inefficiency and inflexibility of static allocation for the guest OSes. In addition, ARMvisor uses R-Map to take care of protecting the memory space of the guest OS. For I/O virtualization, ARMvisor relies on QEMU to emulate I/O devices. We have implemented KVM on ARM-based Linux kernel for all three components in ARMvisor. At this time, we can successfully run a guest Ubuntu system on an Ubuntu host OS with ARMvisor on the ARM-based TI BeagleBoard.
14
Homework 6-5:strstr練習 Sample output
The keyword “ARM” has been found for 9 times. It has been found for the first time in “ARMvisor uses trad”
15
Deadline 12/13
Similar presentations