do u know why nobody answer your problem? not your question is very difficult. 看来只有我这种富有同情心的菜鸟来回答你这个连菜鸟都算不上的问题,去查帮助文档中的CFile类吧,
my god. it doesnt worth using my super cow mind to implement . hehehe....
CFile 异常好用,不过好象存的文件不是binary的。
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
以上是save method,但怎么用呢?
这问题很普通呀,我认为vc中将数据存成文件和普通的C++没什么区别,用运行时库既可以解决。
这是什么错? 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)
not your question is very difficult.
看来只有我这种富有同情心的菜鸟来回答你这个连菜鸟都算不上的问题,去查帮助文档中的CFile类吧,
hehehe....
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
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)
[email protected]
{
CFileDialog dlg(FALSE,"*.*",*.*);
if(dlg.DoModal()!=IDOK)
return FALSE;
CFile file;
if(!file.Open(dlg.GetPathName(),CFile::modeWrite))
return FALSE;
//在此写数据
File.Close();
return TRUE;
}
用 c的库函数如:fopen\fwrite\fopen\fclose 或 MFC的CFile类 或 API 都行。这种标题真令人讨厌!
拜托大家都是VC程序员,
熟归熟,你再这样发贴子,我一样会告你诽谤的。
#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;}
//......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>
我faint~~~~~~~~~~~~~~!!
不要以为老常问的是很简单的问题,当一个写了20年程序老同志问起一个关于如何写文件的问题时,往往意味着…………这个世界就快要到末日了,啊————————————!
快给分吧。