W7 - 1 WORKSHOP7~INPUTFROMA FILE CSIS1117A2009/11/04...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
1 WORKSHOP 7 ~ INPUT FROM A  FILE CSIS 1117A 2009/11/04
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 OUTLINE String Input from a file Read the data in a file Use of Array
Background image of page 2
3 Use the “getline” function Read from the console input to your string  variable getline(cin, string) READ A LINE
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Use the “find” function E.g. Find the position of character “a” in  “mystring” mystring.find(“a”) SEARCH IN A STRING
Background image of page 4
5 How about search the position of the second  character “a”? mystring.find(“a”, start_position) SEARCH IN A STRING (2)
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 EXERCISE 1 – STRING Consider the following input line: Please visit our website to know more about the <a  href=" www.hku.hk ">University of Hong Kong</a>.  You are required to write a program (ex1.cpp) to  initialize a string by the above input line The program will print out the link and title Link: www.hku.hk Title: University of Hong Kong
Background image of page 6
7 EXERCISE 1 – STRING (guidelines) i. To read an entire line from cin into a string variable line. ii.
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 22

W7 - 1 WORKSHOP7~INPUTFROMA FILE CSIS1117A2009/11/04...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online