在线等哦,原理上画图跟ofstream一点关系都没有,怎么open之后,没有文件创建呢?

解决方案 »

  1.   

      ofstream ofile;
    ofile.open("dataInfo.info",ios_base::out|ios_base::trunc);

    ofile.flush();
    if (!ofile)
    {
    MessageBox(_T("数据无法保存,请联系管理员"));
    return ;
    }
    for (size_t i = 0 ; i<glInfos.size();i++)
    {
    //索引
    ofile<<glInfos[i].index<<endl;
    //..标题
    TCHAR *wch;
    char ch[100];
    wch = glInfos[i].title.GetBuffer();
    WideCharToMultiByte(CP_ACP,0,wch,-1,ch,100,NULL,NULL);
    ofile<<ch<<endl;
    glInfos[i].title.ReleaseBuffer();
    //...类型
    ofile<<glInfos[i].style<<endl;
    //...图片集个数、图片集
    ofile<<glInfos[i].picStrVec.size()<<endl;
    for(int j = 0; j<glInfos[i].picStrVec.size();j++)
    {
    wch = glInfos[i].picStrVec[j].GetBuffer();
    WideCharToMultiByte(CP_ACP,0,wch,-1,ch,100,NULL,NULL);
    ofile<<ch<<endl;
    }
    //.....人物名
    wch = glInfos[i].title.GetBuffer();
    WideCharToMultiByte(CP_ACP,0,wch,-1,ch,100,NULL,NULL);
    ofile<<ch<<endl;
    glInfos[i].perName.ReleaseBuffer();

    //...人物介绍
    wch = glInfos[i].perIntro.GetBuffer();
    WideCharToMultiByte(CP_ACP,0,wch,-1,ch,100,NULL,NULL);
    ofile<<ch<<endl;
    glInfos[i].perIntro.ReleaseBuffer();
    //....人物头像
    wch = glInfos[i].perPic.GetBuffer();
    WideCharToMultiByte(CP_ACP,0,wch,-1,ch,100,NULL,NULL);
    ofile<<ch<<endl;
    glInfos[i].title.ReleaseBuffer();
    //.....总发言时间
    ofile<<glInfos[i].totalTime<<endl;
    //...单次发言时间
    ofile<<glInfos[i].eachTime<<endl;
    }
    ofile.close();
    ofile.clear();
      

  2.   

    之后为了试验
    我先open()紧跟着
    在close();
    图片如果不画,有文件产生,可是画图片之后,就没有文件了