⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 io20_6.05.c

📁 C++ PRIME书中的原代码,看本书时可以学习的例子.
💻 C
字号:
// #include <fstream>
#include <fstream.h>
#include <string>

/**
 ** requires that these files exist in the directory
 ** this program is executed within
 **
 stanl@john:d.ch20 249 : a.out

 ok: file open: Melville
 ok: file open: Joyce
 ok: file open: Musil
 ok: file open: Proust
 ok: file open: Kafka
 **
 **/


const int fileCnt = 5;
string fileTabl[ fileCnt ] = {
    "Melville", "Joyce", "Musil", "Proust", "Kafka"
};

int main()
{
    ifstream inFile; // not attached to any file

    for ( int ix = 0; ix < fileCnt; ++ix )
    {
          inFile.open( fileTabl[ix].c_str() );
	  if ( ! inFile ) 
	       cerr << "oops! unable to open file: "
		    << fileTabl[ix] << endl;
	  else cerr << "ok: file open: "
		    << fileTabl[ix] << endl;

          // ... process file

          inFile.close();
    }
}

⌨️ 快捷键说明

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