cppstr.cpp

来自「此为本书的配套光盘.本书不但由浅入深地讲解了软件保护技术」· C++ 代码 · 共 68 行

CPP
68
字号
/********************************************************************

	Copyright (c) Beijing Feitian Technologies
	http://www.FTSafe.com

	File :		cppstr.cpp	

	Created:	2003/11/04

	Author:		yihai
	
	Purpose:	?

	Revision:	?

*********************************************************************/
// cppstr.cpp : Defines the entry point for the application.
//

#include "stdafx.h"
#include <afx.h>

#include <string>
#include <fstream>
using namespace std;

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{
		ifstream fin("a.txt");
		if(!fin.is_open())
		{
			MessageBox(NULL, "Can not open a.txt", "Err", MB_OK);
		}
		else
		{
			string strInfo("");
			getline(fin, strInfo);
			MessageBox(NULL, strInfo.c_str(), "Info", MB_OK);
			fin.close();
		}


	CString  str = "haha";
	SYSTEMTIME  st;
	GetSystemTime(&st);
	str.Format("haha %02d:%02d:%02d",st.wHour,st.wMinute,st.wSecond);
	MessageBox(NULL,str,"caption",MB_OK);
	
	try
	{
		CStdioFile	file("a.txt",CFile::modeRead|CFile::typeText);		
		file.ReadString(str);
		MessageBox(NULL,str,"caption",MB_OK);
		file.Close();
	}
	catch (CFileException *pe)
	{
		pe->ReportError();
	}
	return 0;
}



⌨️ 快捷键说明

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