?? wordlist2.cpp
字號:
//: C20:WordList2.cpp
// From Thinking in C++, 2nd Edition
// Available at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
// Eliminating strtok() from Wordlist.cpp
#include "../require.h"
#include <string>
#include <cstring>
#include <set>
#include <iostream>
#include <fstream>
#include <iterator>
using namespace std;
int main(int argc, char* argv[]) {
using namespace std;
requireArgs(argc, 1);
ifstream in(argv[1]);
assure(in, argv[1]);
istreambuf_iterator<char> p(in), end;
set<string> wordlist;
while (p != end) {
string word;
insert_iterator<string>
ii(word, word.begin());
// Find the first alpha character:
while(!isalpha(*p) && p != end)
p++;
// Copy until the first non-alpha character:
while (isalpha(*p) && p != end)
*ii++ = *p++;
if (word.size() != 0)
wordlist.insert(word);
}
// Output results:
copy(wordlist.begin(), wordlist.end(),
ostream_iterator<string>(cout, "\n"));
} ///:~
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -