읽기 방법: 단어 단위로 읽고, 단어를 공백으로 구분하고, "."가 나타나면 읽기를 중지하고, 반환된 내용을 벡터에 저장합니다
//read data from the file, Word By Word //when used in this manner, we'll get space-delimited bits of text from the file //but all of the whitespace that separated words (including newlines) was lost. //http://www.sharejs.com vector<string> ReadDataFromFileWBW() { ifstream fin("Input.txt"); string strWord(""); vector<string> v; while( fin >> strWord ) { //字符串string类的比较要用compare函数 if (strWord.compare(strWord.length()-1, 1, ".") == 0) { strWord.erase(strWord.length()-1, 1); v.push_back(strWord); return v; } v.push_back(strWord); } }