用串行化处理
if (ar.IsStoring())
{
   ar<<...<<...;
}
else
{
   ar>>...>>,,,;
}

解决方案 »

  1.   

    do u know why nobody answer your problem?
    not your question is very difficult.
    看来只有我这种富有同情心的菜鸟来回答你这个连菜鸟都算不上的问题,去查帮助文档中的CFile类吧,
      

  2.   

    my god. it doesnt worth using my super cow mind to implement .
    hehehe....
      

  3.   

    CFile 异常好用,不过好象存的文件不是binary的。
      

  4.   

    Save Method
    Home Page (Objects) |  Overview |  FAQ |  ReferenceApplies to: Document object, TextDocument objectSaves a document to a file.Syntaxobject.Save ( [FullName][, PromptUser] )ParametersobjectAn expression that evaluates to a Document object or a TextDocument object.FullName(Optional) A Variant that is a String specifying the full path to the file in which you want to save the document. If you omit the name, it defaults to the name specified by the FullName property.PromptUser(Optional) A Variant that is a Boolean indicating whether to prompt the user to save changes. Possible values are: True   Prompts the user to save changes. If the user chooses not to save changes, Save returns the enum dsSaveStatus with the value dsSaveSucceeded; otherwise Save returns dsSaveStatus with the value dsSaveCanceled.
    False   Does not prompt the user (the default). 
    Return ValuesThe Save method returns the enum dsSaveStatus, which has one of the following values: dsSaveCanceled   Indicates that the user chose not to save changes to the document.
    dsSaveSucceeded   Indicates that the user saved changes to the document. 
    ExampleThe following example saves a document to "C:\Document\Mydoc.txt":ActiveDocument.Save ("c:\document\mydoc.txt")
    --------------------------------------------------------------------------------Send feedback to MSDN.Look here for MSDN Online resources
      

  5.   

    以上是save method,但怎么用呢?
      

  6.   

    这问题很普通呀,我认为vc中将数据存成文件和普通的C++没什么区别,用运行时库既可以解决。
      

  7.   

    这是什么错?
    void CXDoc::Serialize(CArchive& ar)
    {
    int i;
    Calculate();
    for(i=1;i<716;i++)
    {
    if (ar.IsStoring())
    {
    ar<<w4[i];
    }
    else
    {
    ar>>w4[i];// TODO: add loading code here
    }

    }

    }
    error C2678: binary '<<' : no operator defined which takes a left-hand operand of type 'class CArchive' (or there is no acceptable conversion)
      

  8.   

    晕倒,随便用序列化,或api,或cfile,或c的file操作都可呀。
      

  9.   

    我也要!謝謝!
    [email protected]
      

  10.   

    w4[i]不支持串行化,你能具体讲讲w4是什么数据类型吗?
      

  11.   

    如果不行,或者你可以这么做:bool CXXXView::OnSaveas()
    {
       CFileDialog dlg(FALSE,"*.*",*.*);
       if(dlg.DoModal()!=IDOK)
    return FALSE;
       CFile file;
       if(!file.Open(dlg.GetPathName(),CFile::modeWrite))
           return FALSE;
       //在此写数据
       File.Close();
       return TRUE;
    }
      

  12.   

    w4是什么数据类型,它支持串行化吗? 
    用 c的库函数如:fopen\fwrite\fopen\fclose 或 MFC的CFile类 或 API 都行。这种标题真令人讨厌!
      

  13.   

    我KAO!!!!!我以为学VC的多牛呢,原来也问这么水的问题。
      

  14.   

    FAINT...
    拜托大家都是VC程序员,
    熟归熟,你再这样发贴子,我一样会告你诽谤的。
      

  15.   


    #include <fstream.h>main() {
      
     int i;
     cin >> i; char c;
     cin >> c; ofstream out("filename.txt");
     assert(out); out << "input int:" << i << endl;
     out << "input char:" << c << endl;}
      

  16.   

    FILE *f; //标准C的文件仍然可以用
    //......if((f=fopen("文件名","wb"))!=NULL)  //打开文件
     {
       fwrite(Buf, 1, n, f);            //把Buf的内容的n个字节保存到文件f里(二进制格式)
       fprintf(f, "%d\r\n", AnInteger);     //字符格式输出到文件
       fputs(AString,f);                //把字符串存到文件里
       //....
       fclose(f);  //关闭文件
     }别忘了标准C的头文件
    #include <stdio.h>
      

  17.   

    就这问题?
    我faint~~~~~~~~~~~~~~!!
      

  18.   

    what?没学过流类库?太easy了!(refer to(三楼)iwastired's answer)
      

  19.   

    xxcc , 会不会又是 常新老师?  口气很象哦.
      

  20.   

    对于写过OS的CX(常新)老师,问这种问题,大家难道觉得很奇怪吗?
    不要以为老常问的是很简单的问题,当一个写了20年程序老同志问起一个关于如何写文件的问题时,往往意味着…………这个世界就快要到末日了,啊————————————!
    快给分吧。
      

  21.   

    看来,以后这种标题我是不敢来了,老哥你够cool,真是标题如此多娇,引无数高手笑折腰....
      

  22.   

    如果你愿意从头学起(C,C++,VC),你可以学到许多方法!我建议你从头看起!!!!!!!!!!!!!!!!!!!!
      

  23.   

    如果你愿意从头学起(C,C++,VC),你可以学到许多方法!我建议你从头看起!!!!!!!!!!!!!!!!!!!!