📄 outfile.cpp
字号:
// OutFile.cpp: implementation of the OutFile class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "Mplan.h"
#include "OutFile.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
OutFile::OutFile( ) {
fp = NULL; // 未打开时
}
OutFile::~OutFile( ) {
if( fp != NULL ) Close( ); // 先关闭
}
int OutFile::Open( char nam[ ] ) {
if( fp == NULL ) // 未打开时
fp = fopen( nam,"w"); // 打开
return fp != NULL; // 成功否?
}
void OutFile::Close( ) {
if( fp != NULL ) fclose( fp );
fp = NULL; // 关闭后
}
// 响应具有不同属性的 Write 消息
int OutFile::Write( int v ) {
if( fp == NULL ) return 0;
return fprintf(fp, "%d\t", v) >= 0;
} // 出错时,返回 0
int OutFile::Write( double v ) {
if( fp == NULL ) return 0;
return fprintf(fp, "%lf\n", v) >= 0;
}
int OutFile::Write( char s[ ] ) {
if( fp == NULL ) return 0;
return fprintf(fp, "%s\t", s) >= 0;
} // 用返回值表示出错信息
// 出错信息不输出到 cout
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -