listcount.cpp

来自「C++&datastructure书籍源码,以前外教提供现在与大家共享」· C++ 代码 · 共 27 行

CPP
27
字号
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

#include "clist.h"
#include "prompt.h"

int main()
{
    string filename = PromptString("enter filename ");
    ifstream input(filename.c_str());
    string word;
    
    StringList slist;
    while (input >> word)
    {   slist = cons(word,slist);
    }
    
    StringListIterator it(slist); 
    for(it.Init(); it.HasMore(); it.Next())
    {   cout << it.Current() << endl;
    }
    cout << slist.Size() << " words read " << endl;
    
    return 0;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?