ofstream 对象使用注意

1159阅读 0评论2008-08-31 vfdff
分类:C/C++

// VS6 2008/8/30

#include
#include
#include
using namespace std;

struct data{
    unsigned type    :    2 ;
    unsigned d        :    1 ;
    unsigned context:    5 ;
};

// ofstream 对象不能复制,只能引用传参
void fprint(ofstream &file,struct data t)
{
    int temp = (t.type<<6) + (t.d<<5) + t.context;
    if (temp<16)
    {
        file<    }
    file<}

int main(void)
{
    int j;
    ofstream fsOut("TestData.dat");
    
    for(j=0;j<16;j++)
    {
        int j1=(j&8)&&1,j2=(j&4)&&1,j3=(j&2)&&1,j4=j&&1;
        fsOut<    }

    struct data t;
    t.type = 2;
    t.d = 0;
    t.context = 0x12;
    fprint(fsOut,t);
    fsOut.close();
    cout<    return 0;
}

 
上一篇:没有了
下一篇:减小vc编译文件体积