longadd.cpp

来自「在Visual C++6.0 WinXp下编译通过采用类来实现,从CString」· C++ 代码 · 共 68 行

CPP
68
字号
// LongAdd.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "afx.h"
#include "conio.h"
#include "LongCal.h"
/*void pmain(int argc, char* argv[])
{
	CLongCal a,b;
	a.iniUseString("-1");
	b.iniUseString("10");
	a.Add(b);
	a.toString();
	//CString str("22");
	//printf("\n%d",str.GetLength());
	getch();
}
*/
int main(int argc, char* argv[])
{
	if(argc==1)
	{
		printf("格式:LongAdd 数据文件名!\r\n");
		return 0;
	}
	else if(argc>=3)
	{
		printf("参数太多!\r\n格式:LongAdd 数据文件名!\r\n");
		return 0;
	}
	else
	{
		CStdioFile hfile;
		if( !hfile.Open( argv[1], CFile::modeRead, NULL))
		{
			hfile.Close();
			printf("数据文件打开出错!请确认数据文件的存在!\r\n");
			return 1;

		}
		else
		{   
			CLongCal base("0");/////reverse format
			CLongCal tobase;
			CString str_tobase;
			while(hfile.GetPosition()<(hfile.GetLength()-1))
			{	
				hfile.ReadString(str_tobase);
			     if(str_tobase.IsEmpty())///blank  
					continue;
			    tobase.iniUseString(str_tobase);
				//if(tobase.isZero()) break;//
				base.Add(tobase);
			    
			}
			base.toString();

		}

     hfile.Close();
	}
	getch();
 return 2;
}


⌨️ 快捷键说明

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