11-8.cpp

来自「清华大学出版社出版的c++程序设计课本」· C++ 代码 · 共 23 行

CPP
23
字号
//11-8.cpp
#include <fstream.h>
#include <fcntl.h>
#include <io.h>
void main()
{
    struct
    {
        double salary;
        char name[23];
    } employee;
    ifstream is("payroll",ios::binary | ios::nocreate);
    if (is)
       {
             is.read((char *) &employee,sizeof(employee));
             cout << employee.name << ' ' << employee.salary << endl;
        }
    else 
    {
        cout << "ERROR: Cannot open file 'payroll'." << endl;
    }
}

⌨️ 快捷键说明

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