精神病危险性评估:VC++中,要输出另一个类中CString类型变量该怎么办?

来源:百度文库 编辑:高校问答 时间:2024/05/05 00:12:03
我用CDataDlg *app = (CDataDlg*)AfxGetApp();创建了类指针,
但f<<app->a<<"\n";会提示操作符<<意义不明确,怎么办?谢谢!!

不知道你那个f是什么
\n 用单引号

给你个例子看看
使用ofstream
需要把
#include <fstream>
using namespace std;
加进去

例子:

ofstream f ("e:\\ttt.log");
if ( f.is_open() )
{
CString str = "hello world ";
f << (const char*)str <<'\n' ;
f.close();
}