⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 read_txtdoc.cpp

📁 用VC++实现的对并行计算和进化计算中分类问题
💻 CPP
字号:
// read_txtDoc.cpp : implementation of the CRead_txtDoc class
//

#include "stdafx.h"
#include "read_txt.h"

#include "read_txtDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CRead_txtDoc

IMPLEMENT_DYNCREATE(CRead_txtDoc, CDocument)

BEGIN_MESSAGE_MAP(CRead_txtDoc, CDocument)
	//{{AFX_MSG_MAP(CRead_txtDoc)
	ON_COMMAND(ID_READ, OnRead)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CRead_txtDoc construction/destruction

CRead_txtDoc::CRead_txtDoc()
{
	// TODO: add one-time construction code here

}

CRead_txtDoc::~CRead_txtDoc()
{
}

BOOL CRead_txtDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

	// TODO: add reinitialization code here
	// (SDI documents will reuse this document)

	return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CRead_txtDoc serialization

void CRead_txtDoc::Serialize(CArchive& ar)
{
	if (ar.IsStoring())
	{
		// TODO: add storing code here
	}
	else
	{
		// TODO: add loading code here
	}
}

/////////////////////////////////////////////////////////////////////////////
// CRead_txtDoc diagnostics

#ifdef _DEBUG
void CRead_txtDoc::AssertValid() const
{
	CDocument::AssertValid();
}

void CRead_txtDoc::Dump(CDumpContext& dc) const
{
	CDocument::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CRead_txtDoc commands

void CRead_txtDoc::OnRead() 
{  
	FILE *file;
	CString str;
	int i,j,count=0;
	double buffer=0.0;
	file=fopen("data1.txt", "r+");
	  if(file==NULL)
	  {
          AfxMessageBox("无法打开数据文件TXT,请检查C盘下是否有TXT数据文件!");
// 		   exit(0);
		  return;
	  }
	  else
	  {
		  fseek( file, 0L, SEEK_SET );
		 /*while()	 
		  {
		        fscanf(file,"%lf",&buffer);
				count++;
		  }*/
		  CFile* pFile = NULL; 
		  long length ; 
          pFile = new CFile("data1.txt", CFile::modeRead | CFile::shareDenyNone);
          length = pFile->GetLength();//读取的为字节数
		  int count=length/20; 
		  double **pp;
		  int  row=count/55;
		  str.Format("%d",row);
          AfxMessageBox(str);
		  pp=new double*[row];
		  for(i=0;i<row;i++)
			  pp[i]=new double[55];
		  fseek( file, 0L, SEEK_SET );
		  for(i=0;i<row;i++)
		  {
			  for(j=0;j<55;j++)   
			  {
               fscanf(file,"%lf",&buffer);
			   pp[i][j]=buffer;
			 // str.Format("%f", pp[i][j]);
		      // AfxMessageBox(str);
			  }
		  }
	  }	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -