我编写了
fstream fs(("d:\\code\\key.txt"), ios::in | ios::out | ios::trunc);
    if (!fs.bad())
    {
         fs << Display << endl;
         fs.close();   
    }总是出现一段与csring类型的dispaly不同的数据,
请问大家该怎么解决这个问题啊,谢谢!!! 

解决方案 »

  1.   

    你的程序是不是MFC的阿,是的话,干嘛用fstream 阿
      

  2.   

    是的啊,是不是用fstream不能输出cstring啊?
      

  3.   

    MFC的话,操作文件用CFile类把
      

  4.   

    Display是啥东西结构体?
    那你重载了operator<<么?
      

  5.   

    解决了,只需要简单的代码段就可以了,谢谢大家了啊
    CFile myFile;if ( myFile.Open( _T("d:\\code\\myfile.txt"), CFile::modeCreate | CFile::modeReadWrite, NULL ) )
    {
        myFile.Write( Display, 54 ); 
    }
    其中54为显示的长度
      

  6.   

    ofstream fs;
    fs.Open("d:\\code\\key.txt");
        if (!fs.bad()) 
        { 
            fs < < Display < < endl; 
            fs.close();  
        }