1 / 15

Introduction to C Programming

Introduction to C Programming. HOMEWORK 6. Homework 6-1 :字串輸入練習. 說明 由使用者在執行程式的時候,指定檔案名稱,程式由使用者指定檔案讀入內容, 將從檔案讀入的內容寫到字串當中, 再把內容輸出到螢幕上 Sample input C:Users Peter Desktoptestbin Debug hw-6-1.exe input.txt Content of input file

Télécharger la présentation

Introduction to C Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to C Programming HOMEWORK 6

  2. Homework 6-1:字串輸入練習 • 說明 • 由使用者在執行程式的時候,指定檔案名稱,程式由使用者指定檔案讀入內容,將從檔案讀入的內容寫到字串當中,再把內容輸出到螢幕上 • Sample input • C:\Users\Peter\Desktop\test\bin\Debug\hw-6-1.exeinput.txt • Contentofinputfile • https://www.google.com.tw/search?q=foo+bar&ie=utf-8&oe=utf-8&aq=t • Sample output • Readfrom:input.txt • Thecontentoffile: • https://www.google.com.tw/search?q=foo+bar&ie=utf-8&oe=utf-8&aq=t

  3. Homework 6-2:strtok練習 • 說明 • 由使用者在執行程式的時候,指定檔案名稱,程式由使用者指定檔案讀入內容,將從檔案讀入的內容寫到字串當中,再先把DomainName和後面的參數切開存到靜態陣列。接下來再把後面的參數,利用「?」切出服務名、利用「&」切出參數,依序切開後存到靜態陣列,最後再將存在靜態陣列當中的每個參數的內容輸出到螢幕上(輸出格式請使用投影片SampleOutput的格式),並寫出總共有幾個參數 • Sample input • C:\Users\Peter\Desktop\test\bin\Debug\hw-6-2.exeinput.txt • Contentofinputfile • https://www.google.com.tw/search?q=foo+bar&ie=utf-8&oe=utf-8&aq=t

  4. Homework 6-2:strtok練習(續) • Sample output • DomainName:www.google.com.tw • Serviceis“search” • No.1argumentis“q=foo+bar” • No.2argumentis“ie=utf-8” • No.3argumentis“oe=utf-8” • No.4argumentis“aq=t” • ============================== • Thereare4argumentsinthisURL.

  5. Homework 6-3:strcmp練習 • 說明 • 由使用者在執行程式的時候,指定檔案名稱,程式由使用者指定檔案讀入內容,將從檔案讀入的內容寫到字串當中,再先把DomainName和後面的參數切開存到靜態陣列。接下來再把後面的參數,依序切開後存到靜態陣列,然後再利用strcmp去掃第一個字串,透過下面的服務列表,印出對應的服務名稱。 • https://www.google.com.tw/search?q=foo+bar&ie=utf-8&oe=utf-8&aq=t

  6. Homework 6-3:strcmp練習

  7. Homework 6-3:strcmp練習(續) • Sample input • C:\Users\Peter\Desktop\test\bin\Debug\hw-6-3.exeinput.txt • Contentofinputfile • https://www.google.com.tw/search?q=foo+bar&ie=utf-8&oe=utf-8&aq=t • https://www.google.com.tw/imghp?q=foo+bar&ie=utf-8&oe=utf-8&aq=t • https://www.google.com.tw/maps?q=foo+bar&ie=utf-8&oe=utf-8&aq=t • https://www.google.com.tw/nwshp?q=foo+bar&ie=utf-8&oe=utf-8&aq=t • https://www.google.com.tw/unknown?q=foo+bar&ie=utf-8&oe=utf-8&aq=t • Sample output • No.1serviceis“WebSearch”. • No.2serviceis“ImageSearch”. • No.3serviceis“MapandStreetView”. • No.4serviceis“News”. • No.5serviceisunknownservice.

  8. Homework 6-4:字串上色 • 說明 • 由使用者在執行程式的時候,指定檔案名稱,程式由使用者指定檔案讀入內容,將從檔案讀入的內容寫到字串當中,在輸出到螢幕上的時候,將service用亮藍色上色輸出,將「?」、「&」等分界符號用亮紅色輸出,將參數用亮黃色輸出。 • Sample input • C:\Users\Peter\Desktop\test\bin\Debug\hw-6-4.exeinput.txt • Contentofinputfile • https://www.google.com.tw/search?q=foo+bar&ie=utf-8&oe=utf-8&aq=t • Sample output • https://www.google.com.tw/search?q=foo+bar&ie=utf-8&oe=utf-8&aq=t

  9. Homework6-4Hint:色碼 參考資料:http://pueblo.sourceforge.net/doc/manual/ansi_color_codes.html

  10. Homework6-4Hint:色碼 • 輸出結果:

  11. Homework 6-5:strstr練習 • 說明 • 由使用者在執行程式的時候,指定檔案名稱,程式由使用者指定檔案讀入內容,將從檔案讀入的內容寫到字串當中,再先把DomainName和後面的參數切開存到靜態陣列。接下來再把後面的參數,利用「?」切出服務名、利用「&」切出參數,依序切開後存到靜態陣列,最後在從「q=keyword」參數當中,取出待找的keyword,然後再從待找檔案(database.txt)當中,去找出keyword所在,若有找到,列出找到keyword幾次、並印出第一個keyword出現的位置與其後面的15個字元。

  12. Homework 6-5:strstr練習 • Sample input • C:\Users\Peter\Desktop\test\bin\Debug\hw-6-5.extinput.txt • Contentofinputfile • https://www.google.com.tw/search?q=ARM&ie=utf-8&oe=utf-8&aq=t

  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 • Thekeyword“ARM”hasbeenfoundfor9times. • Ithasbeenfoundforthefirsttimein“ARMvisor uses trad”

  15. Deadline • 12/13

More Related