files.cpp

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

CPP
34
字号
#include <iostream>#include <iomanip>#include <string>using namespace std;#include "directory.h"#include "prompt.h"// illustrates use of the DirStream and DirEntry classesint main(){    DirStream dir;                // directory information    DirEntry entry;               // one entry from a directory    int num = 0;                  // each file is numbered in output    	string name = PromptString("enter name of directory: ");    dir.open(name);    if (dir.fail())    {   cerr << "could not open directory " << name << endl;        exit(1);    }    for(dir.Init(); dir.HasMore(); dir.Next())    {   entry = dir.Current();        num++;        cout << "(" << setw(3) << num << ") " << setw(12) << entry.Name() << "\t";        if (! entry.IsDir() )        {   cout << entry.Size();        }        cout << endl;    }    return 0;}

⌨️ 快捷键说明

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