11_10.cpp

来自「《C++语言程序设计(第2版)》配套例题程序,不可多得」· C++ 代码 · 共 21 行

CPP
21
字号
#include <fstream.h>
void main()
{
    char ch;
    ifstream tfile("payroll",ios::binary | ios::nocreate);
    if (tfile) 
    {
         while (tfile.good()) 
         {
             streampos here = tfile.tellg();
             tfile.get(ch);
             if (ch==' ')
                  cout << "\nPosition " << here << " is a space";
         }
    }
    else 
    {
         cout << "ERROR: Cannot open file 'payroll'." << endl;
    }
}

⌨️ 快捷键说明

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